use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class SightMaster method getShadowingDirection.
// returns direction of the shadowing
private DIRECTION getShadowingDirection(Unit source, DC_Obj obj) {
if (obj.isTransparent()) {
return null;
}
// if (objComp.getObj().isTransparent()) return false;
DIRECTION direction;
Coordinates orig = source.getCoordinates();
Coordinates c = obj.getCoordinates();
if (checkDirectVerticalShadowing(orig, c)) {
direction = (!PositionMaster.isAbove(orig, c)) ? DIRECTION.UP : DIRECTION.DOWN;
return direction;
}
if (checkDirectHorizontalShadowing(orig, c)) {
direction = (!PositionMaster.isToTheLeft(orig, c)) ? DIRECTION.LEFT : DIRECTION.RIGHT;
return direction;
}
if (PositionMaster.isAbove(orig, c)) {
if (PositionMaster.isToTheLeft(orig, c)) {
direction = DIRECTION.DOWN_RIGHT;
} else {
direction = DIRECTION.DOWN_LEFT;
}
} else {
if (PositionMaster.isToTheLeft(orig, c)) {
direction = DIRECTION.UP_RIGHT;
} else {
direction = DIRECTION.UP_LEFT;
}
}
return direction;
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class Analyzer method getWanderCells.
public static List<? extends DC_Obj> getWanderCells(UnitAI ai) {
DIRECTION d = ai.getGroup().getWanderDirection();
// permittedCells = ai.getGroup().getWanderBlocks();
List<DC_Obj> list = new ArrayList<>();
for (DC_Cell cell : getCells(ai, false, false, true)) {
if (d != null) {
if (DirectionMaster.getRelativeDirection(cell, ai.getUnit()) != d) {
continue;
}
}
if (PositionMaster.getDistance(cell, ai.getUnit()) <= ai.getMaxWanderDistance()) {
list.add(cell);
}
}
if (list.isEmpty()) {
// change direction?
}
return list;
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class LE_ObjMaster method setDirection.
public static void setDirection(Unit obj, Coordinates c) {
List list = new ArrayList<>(Arrays.asList(DIRECTION.values()));
list.add(0, "Center");
int i = DialogMaster.optionChoice("Set direction (none==center)", list.toArray());
DIRECTION d = null;
if (i == -1) {
d = DirectionMaster.getRandomDirection();
// random?
}
if (i > 0) {
d = DIRECTION.values()[i - 1];
}
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class Level method getFacingMapData.
private String getFacingMapData() {
String facingMapData = "";
Map<Coordinates, List<Unit>> multiMap = new HashMap<>();
for (Coordinates c : getDirectionMap().keySet()) {
Map<BattleFieldObject, DIRECTION> map = getDirectionMap().get(c);
for (DC_Obj obj : map.keySet()) {
if (obj instanceof Unit) {
Unit u = (Unit) obj;
DIRECTION facing = map.get(u);
if (facing != null) {
u.setCoordinates(c);
String string = DC_ObjInitializer.getObjString(u);
List<Unit> list = multiMap.get(c);
if (list == null) {
list = new ArrayList<>();
multiMap.put(c, list);
}
list.add(u);
if (list.size() > 1) {
string += list.size() + 1;
}
facingMapData += RandomWizard.getWeightStringItem(string, facing.toString());
}
}
}
}
return facingMapData;
}
use of main.game.bf.Coordinates.DIRECTION in project Eidolons by IDemiurge.
the class ClearShotCondition method checkWallObstruction.
private boolean checkWallObstruction(DC_Obj source, DC_Obj target, Coordinates coordinates) {
if (isUnitTestBreakMode()) {
return false;
}
Boolean result = source.getGame().getVisionMaster().getVisionController().getWallObstructionMapper().get(source.getCoordinates(), source.getGame().getCellByCoordinate(target.getCoordinates()));
if (result != null) {
return result;
}
DIRECTION direction = DirectionMaster.getRelativeDirection(source, target);
// target.setBlockingCoordinate(coordinates);
float angle = getAngle(source.getCoordinates(), target.getCoordinates());
for (Coordinates c : coordinates.getAdjacent()) {
// c
DIRECTION relativeDirection = c.isAdjacent(source.getCoordinates()) ? DirectionMaster.getRelativeDirection(c, coordinates) : DirectionMaster.getRelativeDirection(coordinates, c);
if (BooleanMaster.areOpposite(relativeDirection.growX, direction.growX)) {
continue;
}
if (BooleanMaster.areOpposite(relativeDirection.growY, direction.growY)) {
continue;
}
double distance = PositionMaster.getDistanceToLine(new XLine(source.getCoordinates(), target.getCoordinates()), c);
if (distance > 1) {
continue;
}
if (coordinates.equals(target.getCoordinates()) || !target.getCoordinates().isAdjacent(source.getCoordinates(), false)) // && !coordinates.equals(target.getCoordinates())
// && target.getCoordinates().isAdjacent(source.getCoordinates())
{
double d = PositionMaster.getExactDistance(source.getCoordinates(), target.getCoordinates()) - PositionMaster.getExactDistance(c, source.getCoordinates());
if ((d) <= 0.0) {
// must not be beyond target
continue;
}
d = PositionMaster.getExactDistance(source.getCoordinates(), target.getCoordinates()) - PositionMaster.getExactDistance(coordinates, target.getCoordinates());
if ((d) <= 0.0) {
// must not be behind source
continue;
}
}
// DIRECTION d1 = DirectionMaster.getRelativeDirection(source.getCoordinates(), c);
// DIRECTION d2 = DirectionMaster.getRelativeDirection(target.getCoordinates(), c);
boolean left = false;
if (source.getY() != c.y) {
left = (float) Math.abs(source.getX() - c.x) / Math.abs(source.getY() - c.y) < angle;
}
List<DIRECTION> list = source.getGame().getBattleFieldManager().getWallMap().get(c);
if (list == null) {
continue;
}
for (DIRECTION d : list) {
// TODO does direction matter???
if (d != null) {
if (!d.isDiagonal()) {
continue;
}
}
if (left) {
if (BooleanMaster.areOpposite(d.growX, direction.growX)) {
continue;
}
if (!BooleanMaster.areOpposite(d.growY, direction.growY)) {
continue;
}
}
if (!left) {
if (BooleanMaster.areOpposite(d.growY, direction.growY)) {
// TODO does X/Y interchange?
continue;
}
if (!BooleanMaster.areOpposite(d.growX, direction.growX)) {
// TODO does X/Y interchange?
continue;
}
}
if (target.getOBJ_TYPE_ENUM() == DC_TYPE.BF_OBJ) {
if (target.isInfoSelected()) {
LogMaster.log(1, target + " vs " + coordinates + " distance: " + distance);
}
if (target.isInfoSelected()) {
LogMaster.log(1, angle + " vs " + (float) Math.abs(source.getX() - c.x) / Math.abs(source.getX() - c.y));
}
}
wallObstruction = true;
return true;
}
}
return false;
}
Aggregations