Search in sources :

Example 1 with DOOR_STATE

use of eidolons.game.module.dungeoncrawl.objects.DoorMaster.DOOR_STATE in project Eidolons by IDemiurge.

the class WallMap method draw.

@Override
public void draw(Batch batch, float parentAlpha) {
    batch.setColor(new Color(1, 1, 1, 1));
    if (wallMap == null)
        return;
    Set<Coordinates> set = wallMap.keySet();
    for (Coordinates coordinates : set) {
        if (checkCoordinateIgnored(coordinates))
            continue;
        List<DIRECTION> list = wallMap.get(coordinates);
        boolean hasVertical = false;
        boolean hasHorizontal = false;
        boolean hasDiagonal = false;
        boolean drawCorner = true;
        boolean diagonalCorner = false;
        boolean round = false;
        boolean diamond = false;
        boolean mesh = false;
        Vector2 v = GridMaster.getVectorForCoordinate(coordinates, false, false);
        v.set(v.x, v.y - 128);
        // obj.getVisibilityLevel() != VISIBILITY_LEVEL.CLEAR_SIGHT;
        boolean darken = false;
        String suffix = darken ? "dark" : null;
        if (list == null) {
            diamond = true;
        } else {
            for (DIRECTION side : list) {
                TextureRegion image = getRegion(getWallImageFromSide(side, suffix), suffix);
                if (side.isDiagonal()) {
                    if (list.size() == 1) {
                        round = true;
                    }
                    drawCorner = true;
                    if (// doens't do anything?
                    diagonalCorner) {
                        diagonalCorner = false;
                    } else if (hasDiagonal) {
                        diagonalCorner = true;
                    } else {
                        hasDiagonal = true;
                    }
                } else {
                    if (list.size() > 1) {
                        mesh = true;
                    }
                    if (side.isVertical()) {
                        if (hasVertical) {
                            drawCorner = false;
                        }
                        hasVertical = true;
                    } else {
                        if (hasHorizontal) {
                            drawCorner = false;
                        }
                        hasHorizontal = true;
                    }
                }
                DOOR_STATE doorState = doorMap.get(coordinates);
                if (doorState != null) {
                    Color color = batch.getColor();
                    batch.setColor(new Color(1, 1, 1, fluctuatingAlpha));
                    batch.draw(image, v.x, v.y);
                    batch.setColor(color);
                } else {
                    batch.draw(image, v.x, v.y);
                }
            }
        }
        if (hasHorizontal && hasVertical) {
            drawCorner = true;
        }
        if (diagonalCorner) {
            drawCorner = false;
            Boolean x = null;
            Boolean y = null;
            boolean vertical = false;
            for (DIRECTION side : list) {
                if (!side.isDiagonal()) {
                    drawCorner = true;
                    mesh = true;
                } else {
                    if (y != null) {
                        if (y == side.growY) {
                            vertical = true;
                            break;
                        } else {
                            if (x == side.growX) {
                                break;
                            }
                            mesh = true;
                            continue;
                        // TODO
                        }
                    }
                    y = side.growY;
                    x = side.growX;
                }
            }
            if (!mesh) {
                TextureRegion image = getRegion(vertical ? STD_IMAGES.WALL_CORNER_ALMOND_V : STD_IMAGES.WALL_CORNER_ALMOND_H, suffix);
                batch.draw(image, v.x + (128 - image.getRegionWidth()) / 2, v.y + (128 - image.getRegionHeight()) / 2);
            }
        }
        if (drawCorner) {
            TextureRegion image = getRegion(STD_IMAGES.WALL_CORNER, suffix);
            if (diamond) {
                image = getRegion(STD_IMAGES.WALL_CORNER_DIAMOND, suffix);
            } else if (mesh && hasDiagonal) {
                image = getRegion(STD_IMAGES.WALL_CORNER_MESH, suffix);
            } else if (round) {
                image = getRegion(STD_IMAGES.WALL_CORNER_ROUND, suffix);
            }
            // 
            batch.draw(image, v.x + (128 - image.getRegionWidth()) / 2, v.y + (128 - image.getRegionHeight()) / 2);
        }
    }
    drawDiagonalJoints(batch, set);
    super.draw(batch, parentAlpha);
}
Also used : TextureRegion(com.badlogic.gdx.graphics.g2d.TextureRegion) DOOR_STATE(eidolons.game.module.dungeoncrawl.objects.DoorMaster.DOOR_STATE) Vector2(com.badlogic.gdx.math.Vector2) Color(com.badlogic.gdx.graphics.Color) Coordinates(main.game.bf.Coordinates) DIRECTION(main.game.bf.Coordinates.DIRECTION)

Aggregations

Color (com.badlogic.gdx.graphics.Color)1 TextureRegion (com.badlogic.gdx.graphics.g2d.TextureRegion)1 Vector2 (com.badlogic.gdx.math.Vector2)1 DOOR_STATE (eidolons.game.module.dungeoncrawl.objects.DoorMaster.DOOR_STATE)1 Coordinates (main.game.bf.Coordinates)1 DIRECTION (main.game.bf.Coordinates.DIRECTION)1