Skip to content

Commit

Permalink
Merge branch 'feature/Team4/integrate-enemies' into Team4-GeneralMobs…
Browse files Browse the repository at this point in the history
…-Megan
  • Loading branch information
meganroxburgh committed Sep 10, 2023
2 parents 96da9ae + bdbb628 commit 63cc937
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ private void spawnProjectile(Vector2 position, short targetLayer, int space, in


private void spawnXenoGrunts() {
GridPoint2 minPos = terrain.getMapBounds(0).sub(1, 5);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(1, 25);
GridPoint2 minPos = terrain.getMapBounds(0).sub(1, 0);
GridPoint2 maxPos = terrain.getMapBounds(0).sub(1, 10);
for (int i = 0; i < NUM_GRUNTS; i++) {
GridPoint2 randomPos = RandomUtils.random(maxPos, minPos);
System.out.println(randomPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,19 @@ public void updateMobState() {
case IDLE -> {
if (isTargetVisible()) {
// targets detected in idle mode - start deployment
//owner.getEntity().getEvents().trigger(DEPLOY);
owner.getEntity().getEvents().trigger(DEPLOY);
mobState = STATE.DEPLOY;
}
}

case DEPLOY -> {
// currently deploying,
if (isTargetVisible()) {
//owner.getEntity().getEvents().trigger(FIRING);
if (isTargetVisible() || this.meleeOrProjectile() != null) {
owner.getEntity().getComponent(PhysicsMovementComponent.class).setEnabled(false);
owner.getEntity().getEvents().trigger(FIRING);
mobState = STATE.FIRING;
} else {
//owner.getEntity().getEvents().trigger(STOW);
owner.getEntity().getEvents().trigger(STOW);
mobState = STATE.STOW;
}
}
Expand All @@ -123,7 +124,10 @@ public void updateMobState() {
owner.getEntity().getEvents().trigger(STOW);
mobState = STATE.STOW;
} else {
Entity newProjectile = ProjectileFactory.createMobBall(TARGET, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f));
if (this.meleeOrProjectile() instanceof Melee) {

}
Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f));
newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y));
newProjectile.setScale(-1f, 0.5f);
ServiceLocator.getEntityService().register(newProjectile);
Expand All @@ -139,10 +143,10 @@ public void updateMobState() {
case STOW -> {
// currently stowing
if (isTargetVisible()) {
//owner.getEntity().getEvents().trigger(DEPLOY);
owner.getEntity().getEvents().trigger(DEPLOY);
mobState = STATE.DEPLOY;
} else {
//owner.getEntity().getEvents().trigger(IDLE);
owner.getEntity().getEvents().trigger(IDLE);
mobState = STATE.IDLE;
}
}
Expand All @@ -168,7 +172,6 @@ public void stop() {
*/
@Override
public int getPriority() {
// return -1;
if (status == Status.ACTIVE) {
return getActivePriority();
}
Expand Down Expand Up @@ -223,10 +226,13 @@ private Weapon meleeOrProjectile() {
Weapon chosenWeapon = null;
if (comp != null) {
chosenWeapon = comp.chooseWeapon(hitraycast);
if (chosenWeapon != null) {
}
}

return chosenWeapon;
}

private void setTarget() {
Vector2 newVector = new Vector2(owner.getEntity().getPosition().x - 10f, owner.getEntity().getPosition().y - 2f);
Fixture hitraycast = physics.raycastGetHit(owner.getEntity().getPosition(), newVector, TARGET);
}
}

0 comments on commit 63cc937

Please sign in to comment.