Search in sources :

Example 11 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitEvade.

private void onUnitEvade(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitEvade: no unit found for ID {}.", unitId);
    }
    listener.onUnitEvade(unit);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 12 with Unit

use of org.openbw.bwapi4j.unit.Unit in project BWAPI4J by OpenBW.

the class BW method onUnitRenegade.

private void onUnitRenegade(int unitId) {
    Unit unit = this.units.get(unitId);
    if (unit == null) {
        logger.error("onUnitRenegade: no unit found for ID {}.", unitId);
    }
    listener.onUnitRenegade(unit);
}
Also used : Unit(org.openbw.bwapi4j.unit.Unit) PlayerUnit(org.openbw.bwapi4j.unit.PlayerUnit)

Example 13 with Unit

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

the class DropShipAgent method setCargo.

public void setCargo(Set<Unit> cargo) {
    this.cargoWanted = cargo;
    for (Unit u : this.cargoWanted) {
        if (u instanceof Worker && (((Worker) u).isCarryingMinerals() || ((Worker) u).isCarryingGas())) {
            ((Worker) u).returnCargo();
            ((MobileUnit) u).rightClick(unit, true);
        } else
            ((MobileUnit) u).rightClick(unit, false);
    }
}
Also used : MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) Worker(org.openbw.bwapi4j.unit.Worker) MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) Unit(org.openbw.bwapi4j.unit.Unit)

Example 14 with Unit

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

the class DropShipAgent method checkLoaded.

private void checkLoaded() {
    if (pickingUp == null)
        return;
    Unit transport = ((MobileUnit) pickingUp).getTransport();
    if (transport != null && transport.equals(unit)) {
        cargoLoaded.add(pickingUp);
        cargoWanted.remove(pickingUp);
        pickingUp = null;
    }
}
Also used : MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) Unit(org.openbw.bwapi4j.unit.Unit)

Example 15 with Unit

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

the class DropShipAgent method picking.

private void picking() {
    if (cargoWanted.isEmpty())
        return;
    if (pickingUp == null) {
        double distB = Double.MAX_VALUE;
        for (Unit u : cargoWanted) {
            double distA = Util.broodWarDistance(unit.getPosition(), u.getPosition());
            if (pickingUp == null || distA < distB) {
                pickingUp = u;
                distB = distA;
            }
        }
        if (pickingUp != null) {
            unit.load((MobileUnit) pickingUp);
        }
    } else {
        if (unit.getOrderTarget() != null && unit.getOrderTarget().equals(pickingUp))
            return;
        checkLoaded();
    }
}
Also used : MobileUnit(org.openbw.bwapi4j.unit.MobileUnit) Unit(org.openbw.bwapi4j.unit.Unit)

Aggregations

Unit (org.openbw.bwapi4j.unit.Unit)19 PlayerUnit (org.openbw.bwapi4j.unit.PlayerUnit)11 MobileUnit (org.openbw.bwapi4j.unit.MobileUnit)3 Base (bwem.Base)2 MutablePair (ecgberht.Util.MutablePair)2 Position (org.openbw.bwapi4j.Position)2 MineralPatch (org.openbw.bwapi4j.unit.MineralPatch)2 SCV (org.openbw.bwapi4j.unit.SCV)2 Worker (org.openbw.bwapi4j.unit.Worker)2 DropShipAgent (ecgberht.Agents.DropShipAgent)1 Ecgberht.getGs (ecgberht.Ecgberht.getGs)1 SimInfo (ecgberht.Simulation.SimInfo)1 UnitInfo (ecgberht.UnitInfo)1 Util (ecgberht.Util.Util)1 UtilMicro (ecgberht.Util.UtilMicro)1 Comparator (java.util.Comparator)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1