use of com.watabou.utils.Rect in project pixel-dungeon-remix by NYRDS.
the class RegularLevel method initRooms.
protected boolean initRooms() {
rooms = new HashSet<>();
split(new Rect(0, 0, getWidth() - 1, getHeight() - 1));
if (rooms.size() < 8) {
return false;
}
Room[] ra = rooms.toArray(new Room[rooms.size()]);
for (int i = 0; i < ra.length - 1; i++) {
for (int j = i + 1; j < ra.length; j++) {
ra[i].addNeighbor(ra[j]);
}
}
return true;
}
use of com.watabou.utils.Rect in project pixel-dungeon-remix by NYRDS.
the class Room method addNeighbor.
public void addNeighbor(Room other) {
Rect i = intersect(other);
if ((i.width() == 0 && i.height() >= 3) || (i.height() == 0 && i.width() >= 3)) {
neighbours.add(other);
other.neighbours.add(this);
}
}
use of com.watabou.utils.Rect in project pixel-dungeon-remix by NYRDS.
the class CavesLevel method decorate.
@Override
protected void decorate() {
for (Room room : rooms) {
if (room.type != Room.Type.STANDARD) {
continue;
}
if (room.width() <= 3 || room.height() <= 3) {
continue;
}
int s = room.square();
if (Random.Int(s) > 8) {
int corner = (room.left + 1) + (room.top + 1) * getWidth();
if (map[corner - 1] == Terrain.WALL && map[corner - getWidth()] == Terrain.WALL) {
map[corner] = Terrain.WALL;
}
}
if (Random.Int(s) > 8) {
int corner = (room.right - 1) + (room.top + 1) * getWidth();
if (map[corner + 1] == Terrain.WALL && map[corner - getWidth()] == Terrain.WALL) {
map[corner] = Terrain.WALL;
}
}
if (Random.Int(s) > 8) {
int corner = (room.left + 1) + (room.bottom - 1) * getWidth();
if (map[corner - 1] == Terrain.WALL && map[corner + getWidth()] == Terrain.WALL) {
map[corner] = Terrain.WALL;
}
}
if (Random.Int(s) > 8) {
int corner = (room.right - 1) + (room.bottom - 1) * getWidth();
if (map[corner + 1] == Terrain.WALL && map[corner + getWidth()] == Terrain.WALL) {
map[corner] = Terrain.WALL;
}
}
for (Room n : room.connected.keySet()) {
if ((n.type == Room.Type.STANDARD || n.type == Room.Type.TUNNEL) && Random.Int(3) == 0) {
Painter.set(this, room.connected.get(n), Terrain.EMPTY_DECO);
}
}
}
for (int i = getWidth() + 1; i < getLength() - getWidth(); i++) {
if (map[i] == Terrain.EMPTY) {
int n = 0;
if (map[i + 1] == Terrain.WALL) {
n++;
}
if (map[i - 1] == Terrain.WALL) {
n++;
}
if (map[i + getWidth()] == Terrain.WALL) {
n++;
}
if (map[i - getWidth()] == Terrain.WALL) {
n++;
}
if (Random.Int(6) <= n) {
map[i] = Terrain.EMPTY_DECO;
}
}
}
for (int i = 0; i < getLength(); i++) {
if (map[i] == Terrain.WALL && Random.Int(12) == 0) {
map[i] = Terrain.WALL_DECO;
}
}
placeEntranceSign();
for (Room r : rooms) {
if (r.type == Type.STANDARD) {
for (Room n : r.neighbours) {
if (n.type == Type.STANDARD && !r.connected.containsKey(n)) /* && Random.Int( 2 ) == 0*/
{
Rect w = r.intersect(n);
if (w.left == w.right && w.bottom - w.top >= 5) {
w.top += 2;
w.bottom -= 1;
w.right++;
Painter.fill(this, w.left, w.top, 1, w.height(), Terrain.CHASM);
} else if (w.top == w.bottom && w.right - w.left >= 5) {
w.left += 2;
w.right -= 1;
w.bottom++;
Painter.fill(this, w.left, w.top, w.width(), 1, Terrain.CHASM);
}
}
}
}
}
}
Aggregations