Search in sources :

Example 6 with MobileUnit

use of org.openbw.bwapi4j.unit.MobileUnit in project Ecgberht by Jabbo16.

the class SendScout method execute.

@Override
public State execute() {
    try {
        if (gameState.enemyMainBase == null) {
            if (!gameState.scoutSLs.isEmpty()) {
                List<Base> aux = new ArrayList<>();
                for (Base b : gameState.scoutSLs) {
                    if (gameState.fortressSpecialBLs.containsKey(b))
                        continue;
                    if (gameState.getStrat().name.equals("PlasmaWraithHell")) {
                        if (((MobileUnit) gameState.chosenScout).move(b.getLocation().toPosition())) {
                            return State.SUCCESS;
                        }
                    } else if (Util.isConnected(b.getLocation(), gameState.chosenScout.getTilePosition())) {
                        if (((MobileUnit) gameState.chosenScout).move(b.getLocation().toPosition())) {
                            return State.SUCCESS;
                        }
                    } else
                        aux.add(b);
                }
                gameState.scoutSLs.removeAll(aux);
            }
        }
        if (gameState.getStrat().name.equals("PlasmaWraithHell")) {
            ((MobileUnit) gameState.chosenScout).stop(false);
            gameState.chosenScout = null;
            return State.FAILURE;
        }
        gameState.workerIdle.add((Worker) gameState.chosenScout);
        ((MobileUnit) gameState.chosenScout).stop(false);
        gameState.chosenScout = null;
        return State.FAILURE;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) ArrayList(java.util.ArrayList) Base(bwem.Base)

Aggregations

MobileUnit (org.openbw.bwapi4j.unit.MobileUnit)6 Unit (org.openbw.bwapi4j.unit.Unit)3 Base (bwem.Base)1 ArrayList (java.util.ArrayList)1 Position (org.openbw.bwapi4j.Position)1 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)1 Worker (org.openbw.bwapi4j.unit.Worker)1