use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CavesBossLevel method build.
@Override
protected boolean build() {
setSize(WIDTH, HEIGHT);
Rect space = new Rect();
space.set(Random.IntRange(2, 2 + (int) (width * 0.2f)), Random.IntRange(2, 2 + (int) (height * 0.2f)), Random.IntRange((int) (width * 0.8f - 2), width - 2), Random.IntRange((int) (height * 0.8f - 2), height - 2));
Painter.fillEllipse(this, space, Terrain.EMPTY);
exit = space.left + space.width() / 2 + (space.top - 1) * width();
map[exit] = Terrain.LOCKED_EXIT;
Painter.fill(this, ROOM_LEFT - 1, ROOM_TOP - 1, ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL);
Painter.fill(this, ROOM_LEFT, ROOM_TOP + 1, ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP, Terrain.EMPTY);
Painter.fill(this, ROOM_LEFT, ROOM_TOP, ROOM_RIGHT - ROOM_LEFT + 1, 1, Terrain.EMPTY_DECO);
arenaDoor = Random.Int(ROOM_LEFT, ROOM_RIGHT) + (ROOM_BOTTOM + 1) * width();
map[arenaDoor] = Terrain.DOOR;
entrance = Random.Int(ROOM_LEFT + 1, ROOM_RIGHT - 1) + Random.Int(ROOM_TOP + 1, ROOM_BOTTOM - 1) * width();
map[entrance] = Terrain.ENTRANCE;
boolean[] patch = Patch.generate(width, height, 0.30f, 6, true);
for (int i = 0; i < length(); i++) {
if (map[i] == Terrain.EMPTY && patch[i]) {
map[i] = Terrain.WATER;
}
}
for (int i = 0; i < length(); i++) {
if (map[i] == Terrain.EMPTY && Random.Int(6) == 0) {
map[i] = Terrain.INACTIVE_TRAP;
Trap t = new ToxicTrap().reveal();
t.active = false;
setTrap(t, i);
}
}
for (int i = width() + 1; i < length() - width(); 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 + width()] == Terrain.WALL) {
n++;
}
if (map[i - width()] == Terrain.WALL) {
n++;
}
if (Random.Int(8) <= n) {
map[i] = Terrain.EMPTY_DECO;
}
}
}
for (int i = 0; i < length() - width(); i++) {
if (map[i] == Terrain.WALL && DungeonTileSheet.floorTile(map[i + width()]) && Random.Int(3) == 0) {
map[i] = Terrain.WALL_DECO;
}
}
return true;
}
use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Room method addNeigbour.
public boolean addNeigbour(Room other) {
if (neigbours.contains(other))
return true;
Rect i = intersect(other);
if ((i.width() == 0 && i.height() >= 2) || (i.height() == 0 && i.width() >= 2)) {
neigbours.add(other);
other.neigbours.add(this);
return true;
}
return false;
}
use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.
the class WalkwayRoom method paint.
@Override
public void paint(Level level) {
if (Math.min(width(), height()) > 3) {
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 PlatformRoom method paint.
@Override
public void paint(Level level) {
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.CHASM);
ArrayList<Rect> platforms = new ArrayList<>();
splitPlatforms(new Rect(left + 2, top + 2, right - 2, bottom - 2), platforms);
for (Rect platform : platforms) {
Painter.fill(level, platform.left, platform.top, platform.width() + 1, platform.height() + 1, Terrain.EMPTY_SP);
}
for (Door door : connected.values()) {
door.set(Door.Type.REGULAR);
Painter.drawInside(level, this, door, 2, Terrain.EMPTY_SP);
}
}
use of com.watabou.utils.Rect in project shattered-pixel-dungeon-gdx by 00-Evan.
the class PlatformRoom method splitPlatforms.
private void splitPlatforms(Rect curPlatform, ArrayList<Rect> allPlatforms) {
int curArea = (curPlatform.width() + 1) * (curPlatform.height() + 1);
// chance to split scales between 0% and 100% between areas of 25 and 36
if (Random.Float() < (curArea - 25) / 11f) {
if (curPlatform.width() > curPlatform.height() || (curPlatform.width() == curPlatform.height() && Random.Int(2) == 0)) {
// split the platform
int splitX = Random.IntRange(curPlatform.left + 2, curPlatform.right - 2);
splitPlatforms(new Rect(curPlatform.left, curPlatform.top, splitX - 1, curPlatform.bottom), allPlatforms);
splitPlatforms(new Rect(splitX + 1, curPlatform.top, curPlatform.right, curPlatform.bottom), allPlatforms);
// add a bridge between
int bridgeY = Random.NormalIntRange(curPlatform.top, curPlatform.bottom);
allPlatforms.add(new Rect(splitX - 1, bridgeY, splitX + 1, bridgeY));
} else {
// split the platform
int splitY = Random.IntRange(curPlatform.top + 2, curPlatform.bottom - 2);
splitPlatforms(new Rect(curPlatform.left, curPlatform.top, curPlatform.right, splitY - 1), allPlatforms);
splitPlatforms(new Rect(curPlatform.left, splitY + 1, curPlatform.right, curPlatform.bottom), allPlatforms);
// add a bridge between
int bridgeX = Random.NormalIntRange(curPlatform.left, curPlatform.right);
allPlatforms.add(new Rect(bridgeX, splitY - 1, bridgeX, splitY + 1));
}
} else {
allPlatforms.add(curPlatform);
}
}
Aggregations