Search in sources :

Example 16 with MineralPatch

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

the class CheckMineralWalk method execute.

@Override
public State execute() {
    try {
        if (gameState.chosenScout == null)
            return State.FAILURE;
        if (gameState.walkingMinerals.isEmpty() || gameState.scoutSLs.isEmpty())
            return State.SUCCESS;
        if (movingMineral == null) {
            MineralPatch target = getCloserMineral();
            if (target == null) {
                if (gameState.chosenScout.getOrderTarget() != null)
                    gameState.chosenScout.move(gameState.scoutSLs.iterator().next().getLocation().toPosition());
                return State.SUCCESS;
            }
            movingMineral = target;
            gameState.chosenScout.rightClick(target, false);
            return State.FAILURE;
        } else if (gameState.chosenScout.getDistance(movingMineral) < 32) {
            gameState.chosenScout.move(gameState.scoutSLs.iterator().next().getLocation().toPosition());
            movingMineral = null;
        }
        return State.SUCCESS;
    } catch (Exception e) {
        System.err.println(this.getClass().getSimpleName());
        e.printStackTrace();
        return State.ERROR;
    }
}
Also used : MineralPatch(org.openbw.bwapi4j.unit.MineralPatch)

Aggregations

MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)16 Worker (org.openbw.bwapi4j.unit.Worker)9 Position (org.openbw.bwapi4j.Position)4 SCV (org.openbw.bwapi4j.unit.SCV)4 Area (bwem.Area)3 TilePosition (org.openbw.bwapi4j.TilePosition)3 PlayerUnit (org.openbw.bwapi4j.unit.PlayerUnit)3 MutablePair (ecgberht.Util.MutablePair)2 Unit (org.openbw.bwapi4j.unit.Unit)2 Base (bwem.Base)1 Mineral (bwem.Mineral)1 MapPrinterExample (bwem.example.MapPrinterExample)1 Geyser (bwem.unit.Geyser)1 Mineral (bwem.unit.Mineral)1 Squad (ecgberht.Squad)1 UnitInfo (ecgberht.UnitInfo)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Map (java.util.Map)1 Player (org.openbw.bwapi4j.Player)1