v0.6.0: improved logic for the placement of large standard rooms
This commit is contained in:
parent
01ed933be2
commit
33dd5089f4
|
@ -95,8 +95,14 @@ public abstract class RegularLevel extends Level {
|
|||
initRooms.add( roomExit = new ExitRoom());
|
||||
|
||||
int standards = standardRooms();
|
||||
for (int i = 0; i < standards; i++)
|
||||
initRooms.add(StandardRoom.createRoom());
|
||||
for (int i = 0; i < standards; i++) {
|
||||
StandardRoom s;
|
||||
do {
|
||||
s = StandardRoom.createRoom();
|
||||
} while ((i + s.sizeCat.roomValue) > standards);
|
||||
i += s.sizeCat.roomValue-1;
|
||||
initRooms.add(s);
|
||||
}
|
||||
|
||||
if (Dungeon.shopOnLevel())
|
||||
initRooms.add(new ShopRoom());
|
||||
|
@ -189,8 +195,13 @@ public abstract class RegularLevel extends Level {
|
|||
|
||||
ArrayList<Room> stdRooms = new ArrayList<>();
|
||||
for (Room room : rooms) {
|
||||
if (room instanceof StandardRoom && room != roomEntrance) stdRooms.add(room);
|
||||
if (room instanceof StandardRoom && room != roomEntrance) {
|
||||
for (int i = 0; i < ((StandardRoom) room).sizeCat.roomValue; i++) {
|
||||
stdRooms.add(room);
|
||||
}
|
||||
}
|
||||
}
|
||||
Random.shuffle(rooms);
|
||||
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
||||
|
||||
while (mobsToSpawn > 0) {
|
||||
|
|
|
@ -79,6 +79,7 @@ public class LineBuilder extends RegularBuilder {
|
|||
roomsToBranch.add(multiConnections.get(i));
|
||||
}
|
||||
roomsToBranch.addAll(singleConnections);
|
||||
weightRooms(branchable);
|
||||
createBranches(rooms, branchable, roomsToBranch, branchTunnelChances);
|
||||
|
||||
findNeighbours(rooms);
|
||||
|
|
|
@ -92,6 +92,7 @@ public class LoopBuilder extends RegularBuilder {
|
|||
ArrayList<Room> roomsToBranch = new ArrayList<>();
|
||||
roomsToBranch.addAll(multiConnections);
|
||||
roomsToBranch.addAll(singleConnections);
|
||||
weightRooms(branchable);
|
||||
createBranches(rooms, branchable, roomsToBranch, branchTunnelChances);
|
||||
|
||||
findNeighbours(rooms);
|
||||
|
|
|
@ -25,6 +25,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection.ConnectionRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -98,6 +99,15 @@ public abstract class RegularBuilder extends Builder {
|
|||
|
||||
// *** Branch Placement ***
|
||||
|
||||
protected static void weightRooms(ArrayList<Room> rooms){
|
||||
for (Room r : rooms.toArray(new Room[0])){
|
||||
if (r instanceof StandardRoom){
|
||||
for (int i = 0; i < ((StandardRoom) r).sizeCat.connectionWeight(); i++)
|
||||
rooms.add(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//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 static void createBranches(ArrayList<Room> rooms, ArrayList<Room> branchable,
|
||||
|
@ -160,11 +170,16 @@ public abstract class RegularBuilder extends Builder {
|
|||
continue;
|
||||
}
|
||||
|
||||
for (Room t : connectingRoomsThisBranch){
|
||||
branchable.add(t);
|
||||
branchable.addAll(connectingRoomsThisBranch);
|
||||
if (r.maxConnections(Room.ALL) > 1) {
|
||||
if (r instanceof StandardRoom){
|
||||
for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++){
|
||||
branchable.add(r);
|
||||
}
|
||||
} else {
|
||||
branchable.add(r);
|
||||
}
|
||||
}
|
||||
if (r.maxConnections(Room.ALL) > 1 && Random.Int(2) == 0)
|
||||
branchable.add(r);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
|
|
@ -31,15 +31,21 @@ public abstract class StandardRoom extends Room {
|
|||
|
||||
public enum SizeCategories{
|
||||
|
||||
NORMAL(4, 10),
|
||||
LARGE(10, 14),
|
||||
GIANT(14, 18);
|
||||
NORMAL(4, 10, 1),
|
||||
LARGE(10, 14, 2),
|
||||
GIANT(14, 18, 3);
|
||||
|
||||
public final int minDim, maxDim;
|
||||
public final int roomValue;
|
||||
|
||||
SizeCategories(int min, int max){
|
||||
SizeCategories(int min, int max, int val){
|
||||
minDim = min;
|
||||
maxDim = max;
|
||||
roomValue = val;
|
||||
}
|
||||
|
||||
public int connectionWeight(){
|
||||
return roomValue*roomValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user