if ((actor.getBox().getX()%16 == 0 && actor.getBox().getY()%16 == 0) || actor.getMoveDirection().x + actor.getMoveDirection().y == 0) {
Behaviors.wanderAimlessly(actor);
}
} else if (behavior.equals("projectile")) {
actor.setMoveDirection(new Vector2f((float)FastTrig.cos(direction), (float)FastTrig.sin(direction)));
if (!actor.canMove(actor.getMoveDirection()) || isMovingOffMap(actor, actor.getMoveDirection())) {
actor.destroy();
return;
}
} else if (behavior.equals("hunt")) {
if ((actor.getBox().getX()%16 == 0 && actor.getBox().getY()%16 == 0) || actor.getMoveDirection().x + actor.getMoveDirection().y == 0) {
Entity max = null;
ArrayList<Entity> entities = actor.getMap().getEntities();
for (Entity e : entities) {
if (e.getName().equals("player")) {
max = e;
break;
}
}
if (max == null) {
Behaviors.wanderAimlessly(actor);
} else {
Behaviors.hunt(actor, new Vector2f(max.getBox().getCenterX(), max.getBox().getCenterY()), false);
}
}
} else if (behavior.equals("intercept")) {
if ((actor.getBox().getX()%16 == 0 && actor.getBox().getY()%16 == 0) || actor.getMoveDirection().x + actor.getMoveDirection().y == 0) {
Entity player = null;
ArrayList<Entity> entities = actor.getMap().getEntities();
for (Entity e : entities) {
if (e.getName().equals("player")) {
player = e;
break;
}
}
if (player == null) {
Behaviors.wanderAimlessly(actor);
} else {
Behaviors.hunt(actor, new Vector2f(player.getBox().getCenterX()+player.getLastDirection().x*64, player.getBox().getCenterY()+player.getLastDirection().y*64), false);
}
}
} else if (behavior.equals("flee")) {
if ((actor.getBox().getX()%16 == 0 && actor.getBox().getY()%16 == 0) || actor.getMoveDirection().x + actor.getMoveDirection().y == 0) {
Entity player = null;
ArrayList<Entity> entities = actor.getMap().getEntities();
for (Entity e : entities) {
if (e.getName().equals("player")) {
player = e;
break;
}
}
if (player == null) {
Behaviors.wanderAimlessly(actor);
} else {
Vector2f myPos = new Vector2f(actor.getBox().getCenterX(), actor.getBox().getCenterY());
Vector2f playerPos = new Vector2f(player.getBox().getCenterX(), player.getBox().getCenterY());
double angle = Math.atan2(playerPos.y - myPos.y, playerPos.x - myPos.x) + Math.PI;
Vector2f target = new Vector2f((float)FastTrig.cos(angle)*100 + myPos.x, (float)FastTrig.sin(angle)*100 + myPos.y);
Behaviors.hunt(actor, target, true);
}
}
} else if (behavior.equals("none")) {