Search in sources :

Example 86 with Coordinates

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

the class CoordinatesMaster method getZoneCoordinates.

public static Set<Coordinates> getZoneCoordinates(DC_ActiveObj entity) {
    Effect effect = EffectFinder.getFirstEffectOfClass(entity, SpecialTargetingEffect.class);
    Set<Coordinates> coordinates = null;
    if (effect != null) {
        SpecialTargetingEffect targetEffect = (SpecialTargetingEffect) effect;
        coordinates = targetEffect.getCoordinates();
    }
    return coordinates;
}
Also used : SpecialTargetingEffect(main.ability.effects.container.SpecialTargetingEffect) Coordinates(main.game.bf.Coordinates) SpecialTargetingEffect(main.ability.effects.container.SpecialTargetingEffect) Effect(main.ability.effects.Effect)

Example 87 with Coordinates

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

the class CoordinatesMaster method getAdjacentToSquare.

public static List<Coordinates> getAdjacentToSquare(List<Coordinates> coordinates) {
    List<Coordinates> list = new ArrayList<>();
    int x1 = getMinX(coordinates);
    int x2 = getMaxX(coordinates);
    int y1 = getMinY(coordinates);
    int y2 = getMaxY(coordinates);
    for (int x = x1 - 1; x < x2 + 1; x++) {
        Coordinates c = new Coordinates(x, y1 - 1);
        if (!c.isInvalid()) {
            list.add(c);
        }
        Coordinates e = new Coordinates(x, y2 + 1);
        if (!e.isInvalid()) {
            list.add(e);
        }
    }
    for (int y = y1 - 2; y < y2; y++) {
        Coordinates e = new Coordinates(x1 - 1, y);
        if (!e.isInvalid()) {
            list.add(e);
        }
        Coordinates e2 = new Coordinates(x2 + 1, y);
        if (!e2.isInvalid()) {
            list.add(e2);
        }
    }
    return list;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 88 with Coordinates

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

the class CoordinatesMaster method getCoordinatesStringData.

public static String getCoordinatesStringData(Collection<Coordinates> coordinates) {
    int x1 = getMinX(coordinates);
    int x2 = getMaxX(coordinates);
    int y1 = getMinY(coordinates);
    int y2 = getMaxY(coordinates);
    List<Coordinates> exceptions = new ArrayList<>();
    for (Coordinates c : getCoordinatesWithin(x1, x2, y1, y2)) {
        exceptions.add(c);
    }
    return getBoundsString(x1, x2, y1, y2) + " " + exceptions.toString();
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 89 with Coordinates

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

the class CoordinatesMaster method getAdjacentToBothGroups.

public static List<Coordinates> getAdjacentToBothGroups(Collection<Coordinates> coordinatesPool, Collection<Coordinates> coordinates, Collection<Coordinates> coordinates2) {
    List<Coordinates> list = new ArrayList<>();
    Set<Coordinates> adjacent1 = new HashSet<>();
    for (Coordinates c : coordinatesPool) {
        for (Coordinates c1 : coordinates) {
            if (c.isAdjacent(c1)) {
                adjacent1.add(c1);
            }
        }
    }
    loop: for (Coordinates c : adjacent1) {
        for (Coordinates c2 : coordinates2) {
            if (c.isAdjacent(c2)) {
                list.add(c);
                continue loop;
            }
        }
    }
    return list;
}
Also used : Coordinates(main.game.bf.Coordinates)

Example 90 with Coordinates

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

the class DC_BattleFieldManager method resetWalls.

public void resetWalls() {
    doorMap.clear();
    Map<Coordinates, BattleFieldObject> wallObjects = new HashMap<>();
    for (Obj obj : game.getObjects(DC_TYPE.BF_OBJ)) {
        BattleFieldObject bfObj = (BattleFieldObject) obj;
        if (bfObj.getZ() == game.getDungeon().getZ()) {
            if (bfObj.isWall()) {
                wallObjects.put(obj.getCoordinates(), bfObj);
            }
            if (bfObj instanceof Door) {
                doorMap.put(obj.getCoordinates(), ((Door) bfObj).getState());
            }
        }
    }
    if (wallMap == null) {
        wallMap = new HashMap<>();
    }
    wallMap.clear();
    ArrayList<Coordinates> coordinates = new ArrayList<>(wallObjects.keySet());
    for (Coordinates coordinate : coordinates) {
        BattleFieldObject wall = wallObjects.get(coordinate);
        if (wall.isDead()) {
            continue;
        }
        List<DIRECTION> list = new ArrayList<>();
        for (Coordinates c : coordinate.getAdjacent(false)) {
            BattleFieldObject adjWall = wallObjects.get(c);
            if (adjWall != null) {
                if (adjWall.isWall() && !adjWall.isDead()) {
                    DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
                    list.add(side);
                }
            }
        }
        adjacent: for (Coordinates c : coordinate.getAdjacent(true)) {
            BattleFieldObject adjWall = wallObjects.get(c);
            if (adjWall != null) {
                if (adjWall.isWall() && !adjWall.isDead()) {
                    DIRECTION side = DirectionMaster.getRelativeDirection(coordinate, c);
                    if (!side.isDiagonal()) {
                        continue;
                    }
                    for (DIRECTION s : list) {
                        if (s.isDiagonal()) {
                            continue;
                        }
                        if (side.getXDirection() == s) {
                            continue adjacent;
                        }
                        if (side.getYDirection() == s) {
                            continue adjacent;
                        }
                    }
                    list.add(side);
                }
            }
        }
        if (!list.isEmpty()) {
            if (coordinate == null)
                continue;
            wallMap.put(coordinate, list);
        }
    }
    if (diagonalJoints == null) {
        diagonalJoints = new HashMap<>();
    }
    diagonalJoints.clear();
    loop: for (Coordinates c : wallMap.keySet()) {
        for (DIRECTION s : wallMap.get(c)) {
            if (s.isDiagonal()) {
                // for (Coordinates c :
                // o.getCoordinates().getAdjacentCoordinates(null)) {
                // if (wallObjects.get(c) != null) {
                // if (containsAdjacentDiagonal in X direction
                // }
                // }
                List<DIRECTION> list = diagonalJoints.get(c);
                if (list == null) {
                    list = new ArrayList<>();
                }
                diagonalJoints.put(c, list);
                if (list.size() == 1) {
                    DIRECTION d = list.get(0);
                    if (s.growX)
                        if (!d.growX)
                            continue;
                        else if (d.growX)
                            continue;
                    if (s.growY)
                        if (!d.growY)
                            continue;
                        else if (d.growY)
                            continue;
                }
                list.add(s);
                continue loop;
            }
        }
    }
    wallResetRequired = false;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) DC_Obj(eidolons.entity.obj.DC_Obj) Obj(main.entity.obj.Obj) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION) Door(eidolons.game.module.dungeoncrawl.objects.Door)

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