Пример #1
0
 private void attackingUnit() {
   if (attackedUnit.isDead()) {
     attackedUnit = null;
     unit.setAction(ActionType.NOTHING);
     return;
   }
   MoveBehavior moveBehavior = unit.getMoveBehavior();
   if (((AStarMoveBehavior) moveBehavior)
           .getManhattanDistance(attackedUnit.getPos(), unit.getPos(), false)
       == 1) {
     meleeAttackUnit(attackedUnit);
   } else {
     goToAttackedUnit(moveBehavior);
   }
 }
Пример #2
0
 private void meleeAttackUnit(Unit attackedUnit) {
   Direction direction = rtsWorld.getDirectionByPoints(unit.getPos(), attackedUnit.getPos());
   unit.setDirection(direction);
   unit.setAction(ActionType.MELEE_ATTACK);
 }