diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java index 99c875a29..00b383326 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -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 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 stdRoomIter = stdRooms.iterator(); while (mobsToSpawn > 0) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LineBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LineBuilder.java index 5a52c2cf5..45560945b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LineBuilder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LineBuilder.java @@ -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); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LoopBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LoopBuilder.java index cadee87b3..c36f339be 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LoopBuilder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LoopBuilder.java @@ -92,6 +92,7 @@ public class LoopBuilder extends RegularBuilder { ArrayList roomsToBranch = new ArrayList<>(); roomsToBranch.addAll(multiConnections); roomsToBranch.addAll(singleConnections); + weightRooms(branchable); createBranches(rooms, branchable, roomsToBranch, branchTunnelChances); findNeighbours(rooms); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java index ed150bcf4..cd0276950 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/RegularBuilder.java @@ -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 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 rooms, ArrayList 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++; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index ad8ccccc5..873517621 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -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; } }