use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RegularLevel method initRooms.
protected ArrayList<Room> initRooms() {
ArrayList<Room> initRooms = new ArrayList<>();
initRooms.add(roomEntrance = new EntranceRoom());
initRooms.add(roomExit = new ExitRoom());
int standards = standardRooms();
for (int i = 0; i < standards; i++) {
StandardRoom s;
do {
s = StandardRoom.createRoom();
} while (!s.setSizeCat(standards - i));
i += s.sizeCat.roomValue - 1;
initRooms.add(s);
}
if (Dungeon.shopOnLevel())
initRooms.add(new ShopRoom());
int specials = specialRooms();
SpecialRoom.initForFloor();
for (int i = 0; i < specials; i++) initRooms.add(SpecialRoom.createRoom());
int secrets = SecretRoom.secretsForFloor(Dungeon.depth);
for (int i = 0; i < secrets; i++) initRooms.add(SecretRoom.createRoom());
return initRooms;
}
use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RegularBuilder method createBranches.
// places the rooms in roomsToBranch into branches from rooms in branchable.
// note that the three arrays should be separate, they may contain the same rooms however
protected void createBranches(ArrayList<Room> rooms, ArrayList<Room> branchable, ArrayList<Room> roomsToBranch, float[] connChances) {
int i = 0;
float angle;
int tries;
Room curr;
ArrayList<Room> connectingRoomsThisBranch = new ArrayList<>();
float[] connectionChances = connChances.clone();
while (i < roomsToBranch.size()) {
Room r = roomsToBranch.get(i);
connectingRoomsThisBranch.clear();
do {
curr = Random.element(branchable);
} while (r instanceof SecretRoom && curr instanceof ConnectionRoom);
int connectingRooms = Random.chances(connectionChances);
if (connectingRooms == -1) {
connectionChances = connChances.clone();
connectingRooms = Random.chances(connectionChances);
}
connectionChances[connectingRooms]--;
for (int j = 0; j < connectingRooms; j++) {
ConnectionRoom t = r instanceof SecretRoom ? new MazeConnectionRoom() : ConnectionRoom.createRoom();
tries = 3;
do {
angle = placeRoom(rooms, curr, t, randomBranchAngle(curr));
tries--;
} while (angle == -1 && tries > 0);
if (angle == -1) {
for (Room c : connectingRoomsThisBranch) {
c.clearConnections();
rooms.remove(c);
}
connectingRoomsThisBranch.clear();
break;
} else {
connectingRoomsThisBranch.add(t);
rooms.add(t);
}
curr = t;
}
if (connectingRoomsThisBranch.size() != connectingRooms) {
continue;
}
tries = 10;
do {
angle = placeRoom(rooms, curr, r, randomBranchAngle(curr));
tries--;
} while (angle == -1 && tries > 0);
if (angle == -1) {
for (Room t : connectingRoomsThisBranch) {
t.clearConnections();
rooms.remove(t);
}
connectingRoomsThisBranch.clear();
continue;
}
for (int j = 0; j < connectingRoomsThisBranch.size(); j++) {
if (Random.Int(3) <= 1)
branchable.add(connectingRoomsThisBranch.get(j));
}
if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) {
if (r instanceof StandardRoom) {
for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++) {
branchable.add(r);
}
} else {
branchable.add(r);
}
}
i++;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RegularLevel method createMobs.
@Override
protected void createMobs() {
// on floor 1, 10 rats are created so the player can get level 2.
int mobsToSpawn = Dungeon.depth == 1 ? 10 : nMobs();
ArrayList<Room> stdRooms = new ArrayList<>();
for (Room room : rooms) {
if (room instanceof StandardRoom && room != roomEntrance) {
for (int i = 0; i < ((StandardRoom) room).sizeCat.roomValue; i++) {
stdRooms.add(room);
}
// pre-0.6.0 save compatibility
} else if (room.legacyType.equals("STANDARD")) {
stdRooms.add(room);
}
}
Random.shuffle(stdRooms);
Iterator<Room> stdRoomIter = stdRooms.iterator();
while (mobsToSpawn > 0) {
if (!stdRoomIter.hasNext())
stdRoomIter = stdRooms.iterator();
Room roomToSpawn = stdRoomIter.next();
Mob mob = createMob();
mob.pos = pointToCell(roomToSpawn.random());
if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
mobsToSpawn--;
mobs.add(mob);
// TODO: perhaps externalize this logic into a method. Do I want to make mobs more likely to clump deeper down?
if (mobsToSpawn > 0 && Random.Int(4) == 0) {
mob = createMob();
mob.pos = pointToCell(roomToSpawn.random());
if (findMob(mob.pos) == null && passable[mob.pos] && mob.pos != exit) {
mobsToSpawn--;
mobs.add(mob);
}
}
}
}
for (Mob m : mobs) {
if (map[m.pos] == Terrain.HIGH_GRASS) {
map[m.pos] = Terrain.GRASS;
losBlocking[m.pos] = false;
}
}
}
use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom in project shattered-pixel-dungeon-gdx by 00-Evan.
the class CavesPainter method decorate.
@Override
protected void decorate(Level level, ArrayList<Room> rooms) {
int w = level.width();
int l = level.length();
int[] map = level.map;
for (Room room : rooms) {
if (!(room instanceof EmptyRoom || room instanceof CaveRoom)) {
continue;
}
if (room.width() <= 4 || room.height() <= 4) {
continue;
}
int s = room.square();
if (Random.Int(s) > 8) {
int corner = (room.left + 1) + (room.top + 1) * w;
if (map[corner - 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) {
map[corner] = Terrain.WALL;
level.traps.remove(corner);
}
}
if (Random.Int(s) > 8) {
int corner = (room.right - 1) + (room.top + 1) * w;
if (map[corner + 1] == Terrain.WALL && map[corner - w] == Terrain.WALL) {
map[corner] = Terrain.WALL;
level.traps.remove(corner);
}
}
if (Random.Int(s) > 8) {
int corner = (room.left + 1) + (room.bottom - 1) * w;
if (map[corner - 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) {
map[corner] = Terrain.WALL;
level.traps.remove(corner);
}
}
if (Random.Int(s) > 8) {
int corner = (room.right - 1) + (room.bottom - 1) * w;
if (map[corner + 1] == Terrain.WALL && map[corner + w] == Terrain.WALL) {
map[corner] = Terrain.WALL;
level.traps.remove(corner);
}
}
for (Room n : room.connected.keySet()) {
if ((n instanceof StandardRoom || n instanceof ConnectionRoom) && Random.Int(3) == 0) {
Painter.set(level, room.connected.get(n), Terrain.EMPTY_DECO);
}
}
}
for (int i = w + 1; i < l - w; 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 + w] == Terrain.WALL) {
n++;
}
if (map[i - w] == Terrain.WALL) {
n++;
}
if (Random.Int(6) <= n) {
map[i] = Terrain.EMPTY_DECO;
}
}
}
for (int i = 0; i < l - w; i++) {
if (map[i] == Terrain.WALL && DungeonTileSheet.floorTile(map[i + w]) && Random.Int(4) == 0) {
map[i] = Terrain.WALL_DECO;
}
}
for (Room r : rooms) {
if (r instanceof EmptyRoom) {
for (Room n : r.neigbours) {
if (n instanceof EmptyRoom && !r.connected.containsKey(n)) {
Rect i = r.intersect(n);
if (i.left == i.right && i.bottom - i.top >= 5) {
i.top += 2;
i.bottom -= 1;
i.right++;
Painter.fill(level, i.left, i.top, 1, i.height(), Terrain.CHASM);
} else if (i.top == i.bottom && i.right - i.left >= 5) {
i.left += 2;
i.right -= 1;
i.bottom++;
Painter.fill(level, i.left, i.top, i.width(), 1, Terrain.CHASM);
}
}
}
}
}
}
Aggregations