Search in sources :

Example 11 with Coordinates

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

the class DrawMasterStatic method drawDiagonalJoints.

public static void drawDiagonalJoints(int zoom, Graphics g, int offsetX, int offsetY, int w, int h, Map<Coordinates, java.util.List<Coordinates.DIRECTION>> diagonalJoints) {
    for (Coordinates c : diagonalJoints.keySet()) {
        boolean darken = false;
        Unit obj = DC_Game.game.getUnitByCoordinate(c);
        // TODO CHECK WALL
        if (obj == null) {
            obj = DC_Game.game.getUnitByCoordinate(c);
            continue;
        }
        if (!CoreEngine.isLevelEditor()) {
            if (!obj.isDetected()) {
                if (!DebugMaster.isOmnivisionOn()) // obj.getPlayerVisionStatus(false) !=
                // UNIT_TO_PLAYER_VISION.DETECTED
                {
                    continue;
                }
            }
        }
        if (obj != null) {
            darken = obj.getVisibilityLevel() != VisionEnums.VISIBILITY_LEVEL.CLEAR_SIGHT;
        }
        String prefix = darken ? "dark" : "";
        int x = w * (c.x - offsetX);
        int y = h * (c.y - offsetY);
        if (x < 0) {
            continue;
        }
        if (x > GuiManager.getBattleFieldWidth()) {
            continue;
        }
        if (y < 0) {
            continue;
        }
        if (y > GuiManager.getBattleFieldHeight()) {
            continue;
        }
        java.util.List<Coordinates.DIRECTION> list = diagonalJoints.get(c);
        for (Coordinates.DIRECTION side : list) {
            int x1 = x;
            int y1 = y;
            boolean flipped = false;
            if (side == Coordinates.DIRECTION.DOWN_LEFT) {
                y1 += h;
            } else if (side == Coordinates.DIRECTION.DOWN_RIGHT) {
                x1 += w;
                y1 += h;
                flipped = true;
            } else if (side == Coordinates.DIRECTION.UP_LEFT) {
                flipped = true;
            } else if (side == Coordinates.DIRECTION.UP_RIGHT) {
                x1 += w;
            }
            // if (list.indexOf(side) > 0) {
            // flipped = !flipped;
            // }
            // getOrCreate the rim for this side
            // add offset if necessary
            Image image = ImageManager.STD_IMAGES.WALL_CORNER_ALMOND.getPathPrefixedImage(prefix);
            if (zoom != 100) {
                image = ImageManager.getSizedVersion(image, zoom, true);
            }
            if (flipped) {
                image = ImageTransformer.flipHorizontally(ImageManager.getBufferedImage(image));
            }
            // TODO scale them!
            drawImage(g, image, x1 - image.getWidth(null) / 2, y1 - image.getHeight(null) / 2);
        }
    }
}
Also used : Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) BufferedImage(java.awt.image.BufferedImage)

Example 12 with Coordinates

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

the class BfGridComp method initCellsAndMap.

private void initCellsAndMap() {
    cells = new CellComp[getCellsX()][getCellsY()];
    for (int i = 0; i < getCellsX(); i++) {
        for (int j = 0; j < getCellsY(); j++) {
            DC_Cell cellEntity = new DC_Cell(i, j, game, new Ref(), game.getDungeon());
            Coordinates coordinates = new Coordinates(i, j);
            cellEntityMap.put(coordinates, cellEntity);
            if (!CoreEngine.isLevelEditor())
                continue;
            CellComp cell = new CellComp(game, coordinates, this);
            getMap().put(coordinates, cell);
            cells[i][j] = cell;
        }
    }
}
Also used : Ref(main.entity.Ref) DC_Cell(eidolons.entity.obj.DC_Cell) Coordinates(main.game.bf.Coordinates)

Example 13 with Coordinates

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

the class DC_BattleFieldGrid method resetComponents.

@Deprecated
private void resetComponents() {
    int offsetX = getOffsetX();
    int offsetY = getOffsetY();
    LogMaster.log(0, "resetting grid comps with offsetX = " + offsetX + ";offsetY =" + offsetY);
    for (int i = 0; i < getDisplayedCellsX(); i++) {
        for (int j = 0; j < getDisplayedCellsY(); j++) {
            int x = i + getOffsetX();
            int y = j + getOffsetY();
            Coordinates c = new Coordinates(x, y);
            List<BattleFieldObject> objects = game.getObjectsOnCoordinate(getZ(), c, false, true, false);
            List<Unit> overlayingObjects = new ArrayList<>(new DequeImpl(game.getObjectsOnCoordinate(getZ(), c, true, true, false)).getRemoveAll(objects));
            // visibility preCheck!
            CellComp comp = gridComp.getCells()[x][y];
            List<BattleFieldObject> list = new ArrayList<>();
            for (BattleFieldObject obj : objects) {
                if (VisionManager.checkVisible(obj)) {
                    list.add(obj);
                }
            }
            comp.setSizeFactor(gridComp.getZoom());
            comp.setOverlayingObjects(overlayingObjects);
            if (list.size() != 0) {
            // comp.setObjects(list);
            }
            comp.refresh();
        }
    }
    comp.refresh();
}
Also used : CellComp(eidolons.swing.components.obj.CellComp) BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates) Unit(eidolons.entity.obj.unit.Unit) DequeImpl(main.system.datatypes.DequeImpl)

Example 14 with Coordinates

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

the class DC_BattleFieldGrid method noObstacles.

private boolean noObstacles(int xy, int xy1, int xy2, Obj source, boolean x_y) {
    int max = xy2;
    int min = xy1;
    if (xy1 > xy2) {
        max = xy1;
        min = xy2;
    }
    for (int i = min + 1; i < max; i++) {
        Coordinates c = (x_y) ? new Coordinates(xy, i) : new Coordinates(i, xy);
        List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(getZ(), c, false, false, false);
        for (BattleFieldObject obj : objects) {
            if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
                return false;
            }
        }
    }
    return true;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates)

Example 15 with Coordinates

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

the class DC_BattleFieldGrid method noObstaclesOnDiagonal.

@Override
public boolean noObstaclesOnDiagonal(Coordinates c1, Coordinates c2, Obj source) {
    boolean above = PositionMaster.isAbove(c1, c2);
    boolean left = PositionMaster.isToTheLeft(c1, c2);
    int X = c1.x;
    int Y = c1.y;
    while (X != c2.x || Y != c2.y) {
        if (above) {
            Y++;
        } else {
            Y--;
        }
        if (left) {
            X++;
        } else {
            X--;
        }
        if (X == c2.x || Y == c2.y) {
            break;
        }
        Coordinates c = new Coordinates(X, Y);
        List<BattleFieldObject> objects = game.getMaster().getObjectsOnCoordinate(c, false);
        for (BattleFieldObject obj : objects) {
            if (obj.isObstructing(source, game.getCellByCoordinate(c))) {
                return false;
            }
        }
    }
    return true;
}
Also used : BattleFieldObject(eidolons.entity.obj.BattleFieldObject) Coordinates(main.game.bf.Coordinates)

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