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));
}
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);
}
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;
}
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;
}
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;
}
Aggregations