private List<Point> fillAvailablePointsToMoveNearAttackedUnit(List<Point> availablePointsToMove) {
   Point testPoint;
   testPoint = attackedUnit.getPos().getCopy();
   testPoint.setY(testPoint.getY() + 1);
   if (rtsWorld.canMoveToPoint(testPoint, false)) {
     availablePointsToMove.add(testPoint);
   }
   testPoint = attackedUnit.getPos().getCopy();
   testPoint.setX(testPoint.getX() + 1);
   if (rtsWorld.canMoveToPoint(testPoint, false)) {
     availablePointsToMove.add(testPoint);
   }
   testPoint = attackedUnit.getPos().getCopy();
   testPoint.setY(testPoint.getY() - 1);
   if (rtsWorld.canMoveToPoint(testPoint, false)) {
     availablePointsToMove.add(testPoint);
   }
   testPoint = attackedUnit.getPos().getCopy();
   testPoint.setX(testPoint.getX() - 1);
   if (rtsWorld.canMoveToPoint(testPoint, false)) {
     availablePointsToMove.add(testPoint);
   }
   Collections.shuffle(availablePointsToMove);
   return availablePointsToMove;
 }
 @Override
 public void actionOnPoint(Point point) {
   Unit enemyUnit = rtsWorld.getEnemyUnitInPoint(point, unit.getPlayer());
   if (enemyUnit != null) {
     attackedUnit = enemyUnit;
   } else {
     attackedUnit = null;
     unit.getMoveBehavior().setDestMovePoint(point, false);
   }
 }
 private boolean validePathPicked() {
   List<Point> path = unit.getMoveBehavior().getPath();
   if (path == null) {
     return true;
   }
   Point lastPointPath = path.get(path.size() - 1);
   if (AStarMoveBehavior.getManhattanDistance(unit.getPos(), attackedUnit.getPos())
       <= (AStarMoveBehavior.getManhattanDistance(lastPointPath, attackedUnit.getPos()))) {
     return false;
   }
   return true;
 }
 @Override
 public void update() {
   if (attackedUnit != null) {
     findAndAttackNearbyEnemy();
     attackingUnit();
   } else {
     unit.getMoveBehavior().update();
   }
   if (!unit.getAction().equals(ActionType.NOTHING)) {
     return;
   }
   findAndAttackNearbyEnemy();
 }
 private Point getClosestOpenPointToAttackedUnit() {
   List<Point> availablePointsToMove = new ArrayList<Point>();
   fillAvailablePointsToMoveNearAttackedUnit(availablePointsToMove);
   Point openPoint = null;
   for (Point point : availablePointsToMove) {
     if (openPoint == null
         || Point.getManhattanDistance(openPoint, unit.getPos())
             > Point.getManhattanDistance(point, unit.getPos())) {
       openPoint = point;
     }
   }
   return openPoint;
 }
 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);
   }
 }
 private void findAndAttackNearbyEnemy() {
   Unit candidatUnit = null;
   for (Unit curUnit : rtsWorld.getUnits()) {
     if (curUnit.getPlayer() != unit.getPlayer()) {
       if (AStarMoveBehavior.getManhattanDistance(unit.getPos(), curUnit.getPos())
               < getFindEnemyDistance()
           && (candidatUnit == null
               || AStarMoveBehavior.getManhattanDistance(unit.getPos(), curUnit.getPos())
                   < AStarMoveBehavior.getManhattanDistance(
                       unit.getPos(), candidatUnit.getPos()))) {
         candidatUnit = curUnit;
       }
       /*     if (getEuclideDistance(unit.getPos(), curUnit.getPos()) < getFindEnemyDistance()
               && (candidatUnit == null || getEuclideDistance(unit.getPos(), curUnit.getPos()) < (getEuclideDistance(unit.getPos(), candidatUnit.getPos())))) {
           candidatUnit = curUnit;
       }*/
     }
   }
   if (candidatUnit != null) attackedUnit = candidatUnit;
 }
 @Override
 public void setUnit(Unit unit) {
   this.unit = unit;
   this.rtsWorld = unit.getRtsWorld();
 }
 private void meleeAttackUnit(Unit attackedUnit) {
   Direction direction = rtsWorld.getDirectionByPoints(unit.getPos(), attackedUnit.getPos());
   unit.setDirection(direction);
   unit.setAction(ActionType.MELEE_ATTACK);
 }