Search in sources :

Example 6 with Rect

use of com.watabou.utils.Rect in project pixel-dungeon by watabou.

the class Room method addNeigbour.

public void addNeigbour(Room other) {
    Rect i = intersect(other);
    if ((i.width() == 0 && i.height() >= 3) || (i.height() == 0 && i.width() >= 3)) {
        neigbours.add(other);
        other.neigbours.add(this);
    }
}
Also used : Rect(com.watabou.utils.Rect)

Example 7 with Rect

use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.

the class Tilemap method moveToUpdating.

private synchronized void moveToUpdating() {
    updating = new Rect(updated);
    updated.setEmpty();
}
Also used : Rect(com.watabou.utils.Rect)

Example 8 with Rect

use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RingBridgeRoom method paint.

@Override
public void paint(Level level) {
    Painter.fill(level, this, 1, Terrain.CHASM);
    super.paint(level);
    for (Room r : neigbours) {
        if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom) {
            Rect i = intersect(r);
            if (i.width() != 0) {
                i.left++;
                i.right--;
            } else {
                i.top++;
                i.bottom--;
            }
            Painter.fill(level, i.left, i.top, i.width() + 1, i.height() + 1, Terrain.CHASM);
        }
    }
}
Also used : Rect(com.watabou.utils.Rect) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)

Example 9 with Rect

use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.

the class TunnelRoom method paint.

public void paint(Level level) {
    int floor = level.tunnelTile();
    Rect c = getConnectionSpace();
    for (Door door : connected.values()) {
        Point start;
        Point mid;
        Point end;
        start = new Point(door);
        if (start.x == left)
            start.x++;
        else if (start.y == top)
            start.y++;
        else if (start.x == right)
            start.x--;
        else if (start.y == bottom)
            start.y--;
        int rightShift;
        int downShift;
        if (start.x < c.left)
            rightShift = c.left - start.x;
        else if (start.x > c.right)
            rightShift = c.right - start.x;
        else
            rightShift = 0;
        if (start.y < c.top)
            downShift = c.top - start.y;
        else if (start.y > c.bottom)
            downShift = c.bottom - start.y;
        else
            downShift = 0;
        // always goes inward first
        if (door.x == left || door.x == right) {
            mid = new Point(start.x + rightShift, start.y);
            end = new Point(mid.x, mid.y + downShift);
        } else {
            mid = new Point(start.x, start.y + downShift);
            end = new Point(mid.x + rightShift, mid.y);
        }
        Painter.drawLine(level, start, mid, floor);
        Painter.drawLine(level, mid, end, floor);
    }
    for (Door door : connected.values()) {
        door.set(Door.Type.TUNNEL);
    }
}
Also used : Rect(com.watabou.utils.Rect) Point(com.watabou.utils.Point) Point(com.watabou.utils.Point)

Example 10 with Rect

use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.

the class RegularPainter method placeDoors.

private void placeDoors(Room r) {
    for (Room n : r.connected.keySet()) {
        Room.Door door = r.connected.get(n);
        if (door == null) {
            Rect i = r.intersect(n);
            ArrayList<Point> doorSpots = new ArrayList<>();
            for (Point p : i.getPoints()) {
                if (r.canConnect(p) && n.canConnect(p))
                    doorSpots.add(p);
            }
            if (doorSpots.isEmpty()) {
                ShatteredPixelDungeon.reportException(new RuntimeException("Could not place a door! " + "r=" + r.getClass().getSimpleName() + " n=" + n.getClass().getSimpleName()));
                continue;
            }
            door = new Room.Door(Random.element(doorSpots));
            r.connected.put(n, door);
            n.connected.put(r, door);
        }
    }
}
Also used : Rect(com.watabou.utils.Rect) ArrayList(java.util.ArrayList) Point(com.watabou.utils.Point) EmptyRoom(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom) Room(com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)

Aggregations

Rect (com.watabou.utils.Rect)38 Point (com.watabou.utils.Point)10 Room (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room)6 ArrayList (java.util.ArrayList)4 EmptyRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EmptyRoom)3 ConnectionRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom)1 CaveRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom)1 StandardRoom (com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom)1 ToxicTrap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap)1 Trap (com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap)1 BufferTexture (com.watabou.gltextures.BufferTexture)1 Room (com.watabou.pixeldungeon.levels.Room)1 PointF (com.watabou.utils.PointF)1