use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.
the class DefaultActionHandler method getMoveToCellAction.
public static DC_UnitAction getMoveToCellAction(Unit source, Coordinates c) {
DIRECTION d = DirectionMaster.getRelativeDirection(source.getCoordinates(), c);
FACING_SINGLE f = FacingMaster.getSingleFacing(source.getFacing(), source.getCoordinates(), c);
String name = null;
switch(f) {
case IN_FRONT:
if (d.isDiagonal()) {
// target = Eidolons.getGame().getCellByCoordinate(c);
name = "Clumsy Leap";
break;
}
name = "Move";
break;
case BEHIND:
if (d.isDiagonal())
return null;
name = "Move Back";
break;
case TO_THE_SIDE:
boolean right = !source.getFacing().isVertical() ? d.growY : d.growX;
if (!source.getFacing().isVertical()) {
if (source.getFacing().isCloserToZero())
right = !right;
} else if (!source.getFacing().isCloserToZero())
right = !right;
name = right ? "Move Right" : "Move Left";
break;
case NONE:
break;
}
if (name == null) {
// SoundController.getCustomEventSound(SOUND_EVENT.RADIAL_CLOSED);
return null;
}
return source.getAction(name);
}
use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.
the class PathChoiceMaster method constructStdMoveChoice.
private Choice constructStdMoveChoice(Coordinates targetCoordinate, Coordinates c_coordinate, FACING_DIRECTION c_facing) {
FACING_SINGLE facing = FacingMaster.getSingleFacing(c_facing, c_coordinate, targetCoordinate);
Action moveAction = getMoveAction();
if (facing == UnitEnums.FACING_SINGLE.IN_FRONT) {
if (firstStep) {
if (!moveAction.canBeActivated()) {
return null;
}
}
return new Choice(targetCoordinate, c_coordinate, moveAction);
}
pathBuilder.adjustUnit();
Collection<Action> actions = pathBuilder.getTurnSequenceConstructor().getTurnSequence(UnitEnums.FACING_SINGLE.IN_FRONT, unit, targetCoordinate);
actions.add(moveAction);
// resetUnit();// TODO is that right?
Choice choice = new Choice(targetCoordinate, c_coordinate, actions.toArray(new Action[actions.size()]));
return choice;
}
use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.
the class DC_MovementManager method getFirstAction.
public static Action getFirstAction(Unit unit, Coordinates coordinates) {
FACING_SINGLE relative = FacingMaster.getSingleFacing(unit.getFacing(), unit.getCoordinates(), coordinates);
if (relative == FACING_SINGLE.IN_FRONT) {
if (new CellCondition(UNIT_DIRECTION.AHEAD).check(unit))
return AiActionFactory.newAction("Move", unit.getAI());
}
boolean left = (unit.getFacing().isVertical()) ? PositionMaster.isToTheLeft(unit.getCoordinates(), coordinates) : PositionMaster.isAbove(unit.getCoordinates(), coordinates);
if (unit.getFacing().isMirrored()) {
left = !left;
}
if (!new CellCondition(left ? UNIT_DIRECTION.LEFT : UNIT_DIRECTION.RIGHT).check(unit))
return null;
return AiActionFactory.newAction("Move " + (left ? "Left" : "Right"), unit.getAI());
// List<ActionPath> paths = instance.buildPath(unit, coordinates);
// if (!ListMaster.isNotEmpty(paths)) {
// return null ;
// }
// ActionPath path =paths.get(0);
// for (ActionPath portrait : paths){
// if (portrait.getActions().get(0).getActive().isTurn())
// {
// path = portrait;
// break;
// }
// }
// return path.getActions().get(0);
}
use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.
the class FacingCondition method check.
@Override
public boolean check(Ref ref) {
if (!(ref.getSourceObj() instanceof DC_UnitModel)) {
return false;
}
BattleFieldObject obj1 = (BattleFieldObject) ref.getSourceObj();
DC_Obj obj2;
if (!(ref.getObj(KEYS.MATCH) instanceof BfObj)) {
if (!(ref.getObj(KEYS.MATCH) instanceof DC_HeroSlotItem)) {
return false;
}
obj2 = ((DC_HeroAttachedObj) ref.getObj(KEYS.MATCH)).getOwnerObj();
} else {
obj2 = (DC_Obj) ref.getObj(KEYS.MATCH);
}
boolean result = false;
if (getTemplate() != null) {
Coordinates c = obj2.getCoordinates();
if (obj2.isOverlaying())
if (obj2 instanceof BattleFieldObject) {
DIRECTION d = ((BattleFieldObject) obj2).getDirection();
if (d != null) {
c = c.getAdjacentCoordinate(d.rotate180(), 2);
}
// the coordinate to which unit must be facing in order to face the overlaying obj on the other side
}
if (obj1 == null)
return false;
if (c == null)
return false;
FACING_SINGLE facing = FacingMaster.getSingleFacing(obj1.getFacing(), obj1.getCoordinates(), c);
result = Arrays.asList(templates).contains(facing);
if (facing == UnitEnums.FACING_SINGLE.TO_THE_SIDE) {
if (result) {
if (left_right == null) {
left_right = obj1.checkBool(GenericEnums.STD_BOOLS.LEFT_RIGHT_REACH);
}
if (left_right) {
int degrees = obj1.getFacing().getDirection().getDegrees();
int degrees2 = DirectionMaster.getRelativeDirection(obj1, obj2).getDegrees();
boolean left = degrees > degrees2;
if (left) {
return left_right;
}
return !left_right;
}
}
}
}
return result;
}
use of main.content.enums.entity.UnitEnums.FACING_SINGLE in project Eidolons by IDemiurge.
the class PruneMaster method pruneTargetCells.
public List<Coordinates> pruneTargetCells(Action targetAction, List<Coordinates> list) {
TreeMap<Integer, Coordinates> map = new TreeMap<>(SortMaster.getNaturalIntegerComparator(false));
Coordinates coordinates = targetAction.getSource().getCoordinates();
for (Coordinates c : list) {
int distance = 10 * PositionMaster.getDistance(coordinates, c);
if (!PositionMaster.inLine(c, coordinates)) {
distance += 5;
}
if (PositionMaster.inLineDiagonally(c, coordinates)) {
distance += 2;
}
FACING_SINGLE facing = FacingMaster.getSingleFacing(targetAction.getSource().getFacing(), c, coordinates);
switch(facing) {
case BEHIND:
distance += 12;
break;
case IN_FRONT:
break;
case TO_THE_SIDE:
distance += 6;
break;
}
// TODO KEYS WILL OVERLAP!
map.put(distance, c);
}
for (int i = map.size() - getConstInt(AiConst.DEFAULT_PRUNE_SIZE); i > 0; i--) {
map.remove(map.lastKey());
}
// }
return new ArrayList<>(map.values());
}
Aggregations