Search in sources :

Example 76 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class MiniGrid method addObj.

private void addObj(Obj obj) {
    Coordinates c = obj.getCoordinates();
    MiniObjComp objComp = compMap.get(c);
    if (objComp == null) {
        objComp = new MiniObjComp((DC_Obj) obj, map);
        compMap.put(c, objComp);
    }
    if (MiniGrid.isMouseDragOffsetModeOn()) {
    // mouseMap.put(rect, objComp); //or maybe I can map things
    // dynamically on click!
    } else // if (editMode)
    {
        if (objComp.getComp().getMouseListeners().length != 0) {
            objComp.getComp().removeMouseListener(customMouseListener);
        }
        // if (objComp.getComp().getMouseListeners().length == 0) fails?
        objComp.getComp().addMouseListener(customMouseListener);
    }
    comp.add(objComp.getComp(), getMigString(c));
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) Coordinates(main.game.bf.Coordinates)

Example 77 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PatrolMaster method changeDestination.

private static void changeDestination(Patrol patrol) {
    DIRECTION d = patrol.getDirection();
    if (d == null) {
        patrol.getLeadingUnit();
    }
    if (!patrol.isBackAndForth()) {
        d = DirectionMaster.rotate90(d, patrol.isClockwise());
    } else {
        d = DirectionMaster.flip(patrol.getDirection());
    }
    Coordinates newDestination = getNewDestination(patrol, d);
    patrol.setDestination(newDestination);
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates)

Example 78 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PatrolMaster method isArrived.

public static boolean isArrived(Patrol patrol, GroupAI group) {
    Coordinates destination = patrol.getDestination();
    Unit obj = group.getLeader();
    isBlocked(destination, obj);
    return false;
}
Also used : Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 79 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PatrolMaster method getBlockingUnit.

private static Unit getBlockingUnit(Patrol patrol, UnitAI ai) {
    Unit unit = ai.getUnit();
    DIRECTION direction = DirectionMaster.getRelativeDirection(unit.getCoordinates(), patrol.getDestination());
    // paths.getOrCreate(unit);
    Coordinates coordinates = unit.getCoordinates().getAdjacentCoordinate(direction);
    // TODO more than 1 coordinate?
    // unit.getGame().getUnitByCoordinate(coordinates);
    Unit unitByCoordinate = null;
    // preCheck leader?
    Collection<Unit> units = unit.getGame().getUnitsForCoordinates(coordinates);
    for (Obj u : units) {
        // sort?
        Unit blocker = (Unit) u;
        // if (u == leader)
        if (!blocker.isOwnedBy(ai.getUnit().getOwner())) {
            continue;
        }
        if (!blocker.canMove()) {
            continue;
        }
        unitByCoordinate = blocker;
    }
    return unitByCoordinate;
}
Also used : Obj(main.entity.obj.Obj) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit)

Example 80 with Coordinates

use of main.game.bf.Coordinates in project Eidolons by IDemiurge.

the class PatrolMaster method getPatrolAction.

// similar to wandering but all units must be to the target point
public static Action getPatrolAction(UnitAI ai) {
    Patrol patrol = ai.getGroup().getPatrol();
    if (patrol == null) {
        initPatrol(ai.getGroup());
    }
    Action action = null;
    boolean leader = ai.getGroup().getLeader() == ai.getUnit();
    if (isArrived(patrol, ai)) {
        if (leader) {
            if (checkNewDestination(patrol)) {
                changeDestination(patrol);
            } else {
                action = getIdleAction(patrol, ai);
            }
        }
    } else {
        action = getWaitAction(patrol, ai);
    }
    if (action != null) {
        return action;
    }
    if (patrol.getReturnCoordinates() != null) {
        patrol.setDestination(patrol.getReturnCoordinates());
        patrol.setReturnCoordinates(null);
    }
    Coordinates c = patrol.getDestination();
    if (!leader) {
        Coordinates leaderCoordinates = ai.getGroup().getLeader().getCoordinates();
        DIRECTION direction = DirectionMaster.getRelativeDirection(patrol.getDestination(), leaderCoordinates);
        List<Object> list = new ArrayList<>();
        list.add(leaderCoordinates.getAdjacentCoordinate(direction));
        list.add(leaderCoordinates.getAdjacentCoordinate(DirectionMaster.rotate45(direction, true)));
        list.add(leaderCoordinates.getAdjacentCoordinate(DirectionMaster.rotate45(direction, false)));
        c = leaderCoordinates.getAdjacentCoordinate(direction);
    }
    boolean catchingUp = false;
    // make sure paths stick together! getMaxDistanceForNodes(paths)
    return action;
}
Also used : Action(eidolons.game.battlecraft.ai.elements.actions.Action) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Aggregations

Coordinates (main.game.bf.Coordinates)226 Unit (eidolons.entity.obj.unit.Unit)49 ObjType (main.entity.type.ObjType)30 ArrayList (java.util.ArrayList)29 Obj (main.entity.obj.Obj)28 DC_Obj (eidolons.entity.obj.DC_Obj)22 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)21 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)21 DIRECTION (main.game.bf.Coordinates.DIRECTION)20 Ref (main.entity.Ref)15 MapBlock (eidolons.game.battlecraft.logic.dungeon.location.building.MapBlock)13 DC_Cell (eidolons.entity.obj.DC_Cell)12 Action (eidolons.game.battlecraft.ai.elements.actions.Action)11 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)9 BufferedImage (java.awt.image.BufferedImage)8 DequeImpl (main.system.datatypes.DequeImpl)8 Vector2 (com.badlogic.gdx.math.Vector2)7 DC_UnitAction (eidolons.entity.active.DC_UnitAction)7 ZCoordinates (main.game.bf.ZCoordinates)6 ObjAtCoordinate (main.entity.type.ObjAtCoordinate)5