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);
}
}
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();
}
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);
}
}
}
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);
}
}
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);
}
}
}
Aggregations