Search in sources :

Example 16 with DIRECTION

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;
}
Also used : FACING_DIRECTION(main.game.bf.Coordinates.FACING_DIRECTION) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates)

Example 17 with 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;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) DC_Cell(eidolons.entity.obj.DC_Cell) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList)

Example 18 with DIRECTION

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];
    }
}
Also used : DIRECTION(main.game.bf.Coordinates.DIRECTION)

Example 19 with DIRECTION

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;
}
Also used : DC_Obj(eidolons.entity.obj.DC_Obj) HashMap(java.util.HashMap) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) ArrayList(java.util.ArrayList) List(java.util.List) Unit(eidolons.entity.obj.unit.Unit)

Example 20 with DIRECTION

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;
}
Also used : XLine(main.swing.XLine) DIRECTION(main.game.bf.Coordinates.DIRECTION) Coordinates(main.game.bf.Coordinates)

Aggregations

DIRECTION (main.game.bf.Coordinates.DIRECTION)32 Coordinates (main.game.bf.Coordinates)18 FACING_DIRECTION (main.game.bf.Coordinates.FACING_DIRECTION)11 DC_Obj (eidolons.entity.obj.DC_Obj)9 BattleFieldObject (eidolons.entity.obj.BattleFieldObject)7 Unit (eidolons.entity.obj.unit.Unit)6 ArrayList (java.util.ArrayList)5 Obj (main.entity.obj.Obj)5 DC_Cell (eidolons.entity.obj.DC_Cell)2 FACING_SINGLE (main.content.enums.entity.UnitEnums.FACING_SINGLE)2 Color (com.badlogic.gdx.graphics.Color)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 MoveEffect (eidolons.ability.effects.oneshot.move.MoveEffect)1 DC_ActiveObj (eidolons.entity.active.DC_ActiveObj)1 DC_HeroSlotItem (eidolons.entity.item.DC_HeroSlotItem)1 Structure (eidolons.entity.obj.Structure)1 DC_UnitModel (eidolons.entity.obj.unit.DC_UnitModel)1 GroupAI (eidolons.game.battlecraft.ai.GroupAI)1 UnitAI (eidolons.game.battlecraft.ai.UnitAI)1