From 0d366be632ad05708baf7f0942e70bce6780c072 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 29 Mar 2017 17:52:20 -0400 Subject: [PATCH] v0.6.0: restructured room classes --- .../ShatteredPixelDungeon.java | 6 +-- .../actors/mobs/npcs/Blacksmith.java | 5 +- .../actors/mobs/npcs/Wandmaker.java | 9 ++-- .../levels/CavesLevel.java | 4 +- .../shatteredpixeldungeon/levels/Level.java | 2 +- .../levels/RegularLevel.java | 14 ++--- .../levels/SewerBossLevel.java | 4 +- .../levels/builders/LegacyBuilder.java | 44 +++++++-------- .../levels/features/Chasm.java | 2 +- .../levels/painters/RegularPainter.java | 2 +- .../levels/rooms/MazeRoom.java | 15 +++--- .../levels/rooms/Room.java | 34 +++++++++--- .../levels/rooms/{ => special}/AltarRoom.java | 22 ++++---- .../rooms/{ => special}/ArmoryRoom.java | 32 +++++------ .../rooms/{ => special}/BlacksmithRoom.java | 24 ++++----- .../levels/rooms/{ => special}/CryptRoom.java | 48 ++++++++--------- .../rooms/{ => special}/GardenRoom.java | 28 +++++----- .../rooms/{ => special}/LaboratoryRoom.java | 32 +++++------ .../rooms/{ => special}/LibraryRoom.java | 20 +++---- .../rooms/{ => special}/MagicWellRoom.java | 14 ++--- .../rooms/{ => special}/MassGraveRoom.java | 20 +++---- .../levels/rooms/{ => special}/PitRoom.java | 34 ++++++------ .../levels/rooms/{ => special}/PoolRoom.java | 40 +++++++------- .../rooms/{ => special}/RatKingRoom.java | 28 +++++----- .../rooms/{ => special}/RotGardenRoom.java | 38 ++++++------- .../levels/rooms/{ => special}/ShopRoom.java | 27 +++++----- .../levels/rooms/special/SpecialRoom.java | 20 +++++++ .../rooms/{ => special}/StatueRoom.java | 40 +++++++------- .../rooms/{ => special}/StorageRoom.java | 14 ++--- .../levels/rooms/{ => special}/TrapsRoom.java | 52 +++++++++--------- .../rooms/{ => special}/TreasuryRoom.java | 18 +++---- .../levels/rooms/{ => special}/VaultRoom.java | 18 +++---- .../rooms/{ => special}/WeakFloorRoom.java | 54 +++++++++---------- .../rooms/{ => standard}/EntranceRoom.java | 15 +++--- .../levels/rooms/{ => standard}/ExitRoom.java | 15 +++--- .../rooms/{ => standard}/RitualSiteRoom.java | 16 +++--- .../rooms/{ => standard}/StandardRoom.java | 47 +++++++++------- .../rooms/{ => tunnel}/PassageRoom.java | 23 ++++---- .../levels/rooms/{ => tunnel}/TunnelRoom.java | 53 ++++++++++-------- 39 files changed, 500 insertions(+), 433 deletions(-) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/AltarRoom.java (78%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/ArmoryRoom.java (68%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/BlacksmithRoom.java (75%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/CryptRoom.java (61%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/GardenRoom.java (71%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/LaboratoryRoom.java (70%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/LibraryRoom.java (82%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/MagicWellRoom.java (87%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/MassGraveRoom.java (88%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/PitRoom.java (71%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/PoolRoom.java (78%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/RatKingRoom.java (69%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/RotGardenRoom.java (73%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/ShopRoom.java (95%) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/StatueRoom.java (60%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/StorageRoom.java (85%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/TrapsRoom.java (79%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/TreasuryRoom.java (81%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/VaultRoom.java (84%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => special}/WeakFloorRoom.java (54%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => standard}/EntranceRoom.java (73%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => standard}/ExitRoom.java (72%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => standard}/RitualSiteRoom.java (85%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => standard}/StandardRoom.java (89%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => tunnel}/PassageRoom.java (83%) rename core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/{ => tunnel}/TunnelRoom.java (73%) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java index cea2cc0cd..cf3f316e9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ShatteredPixelDungeon.java @@ -56,13 +56,13 @@ public class ShatteredPixelDungeon extends Game { //v0.6.0 com.watabou.utils.Bundle.addAlias( - com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom.Bones.class, + com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom.Bones.class, "com.shatteredpixel.shatteredpixeldungeon.levels.painters.MassGravePainter$Bones" ); com.watabou.utils.Bundle.addAlias( - com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RitualSiteRoom.RitualMarker.class, + com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RitualSiteRoom.RitualMarker.class, "com.shatteredpixel.shatteredpixeldungeon.levels.painters.RitualSitePainter$RitualMarker" ); com.watabou.utils.Bundle.addAlias( - com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom.HiddenWell.class, + com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom.HiddenWell.class, "com.shatteredpixel.shatteredpixeldungeon.levels.painters.WeakFloorPainter$HiddenWell" ); com.watabou.utils.Bundle.addAlias( com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.class, diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java index 10fad3906..c80fe5f03 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Blacksmith.java @@ -32,9 +32,9 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold; import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe; import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.BlacksmithRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.BlacksmithRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite; @@ -279,6 +279,7 @@ public class Blacksmith extends NPC { } } + //FIXME: refactor this to work with new levelgen public static boolean spawn( ArrayList rooms ) { if (!spawned && Dungeon.depth > 11 && Random.Int( 15 - Dungeon.depth ) == 0) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index eaf3468ba..5e2b747a9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -33,11 +33,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust; import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RitualSiteRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RotGardenRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RotGardenRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RitualSiteRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -283,6 +283,7 @@ public class Wandmaker extends NPC { } } + //FIXME: refactor this to work with new levelgen public static boolean spawnRoom( ArrayList rooms) { questRoomSpawned = false; if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int( 10 - Dungeon.depth ) == 0))) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java index db118b853..0ffa89607 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java @@ -25,8 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TunnelRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.TunnelRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index f343c011c..df6b1d443 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -68,7 +68,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm; import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door; import com.shatteredpixel.shatteredpixeldungeon.levels.features.HighGrass; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; 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 972951b0d..13c889928 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -36,12 +36,12 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.RegularPainter; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.EntranceRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ExitRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PitRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom; +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.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; @@ -157,7 +157,7 @@ public abstract class RegularLevel extends Level { ArrayList stdRooms = new ArrayList<>(); for (Room room : rooms) { - if (room instanceof StandardRoom) stdRooms.add(room); + if (room instanceof StandardRoom && room != roomEntrance) stdRooms.add(room); } Iterator stdRoomIter = stdRooms.iterator(); @@ -346,7 +346,7 @@ public abstract class RegularLevel extends Level { @Override public int pitCell() { for (Room room : rooms) { - if (room instanceof PitRoom) { + if (room instanceof PitRoom || room.legacyType.equals("PIT")) { return pointToCell(room.random()); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java index 175b9d03e..9f9cb0404 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerBossLevel.java @@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.watabou.noosa.Group; @@ -140,7 +140,7 @@ public class SewerBossLevel extends RegularLevel { Room room; do { room = Random.element(rooms); - } while (!(room instanceof StandardRoom)); + } while (!(room instanceof StandardRoom) || room == roomEntrance); mob.pos = pointToCell(room.random()); mobs.add( mob ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java index c92483a65..26162ca12 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/builders/LegacyBuilder.java @@ -7,25 +7,25 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ArmoryRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.CryptRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.EntranceRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ExitRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.GardenRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.LaboratoryRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.LibraryRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MagicWellRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PassageRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PitRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RatKingRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ShopRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StatueRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TreasuryRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TunnelRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.VaultRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ArmoryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.CryptRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.GardenRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LaboratoryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LibraryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicWellRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RatKingRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StatueRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TreasuryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.VaultRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom; +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.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.PassageRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.TunnelRoom; import com.watabou.utils.Graph; import com.watabou.utils.Random; import com.watabou.utils.Rect; @@ -419,14 +419,14 @@ public class LegacyBuilder extends Builder { if (w > maxRoomSize && h < minRoomSize) { - int vw = Random.Int( rect.left + 3, rect.right - 3 ); + int vw = Random.Int( rect.left + (minRoomSize/2), rect.right - (minRoomSize/2) ); split( new Rect( rect.left, rect.top, vw, rect.bottom ) ); split( new Rect( vw, rect.top, rect.right, rect.bottom ) ); } else if (h > maxRoomSize && w < minRoomSize) { - int vh = Random.Int( rect.top + 3, rect.bottom - 3 ); + int vh = Random.Int( rect.top + (minRoomSize/2), rect.bottom - (minRoomSize/2) ); split( new Rect( rect.left, rect.top, rect.right, vh ) ); split( new Rect( rect.left, vh, rect.right, rect.bottom ) ); @@ -438,11 +438,11 @@ public class LegacyBuilder extends Builder { } else { if (Random.Float() < (float)(w - 2) / (w + h - 4)) { - int vw = Random.Int( rect.left + 3, rect.right - 3 ); + int vw = Random.Int( rect.left + (minRoomSize/2), rect.right - (minRoomSize/2) ); split( new Rect( rect.left, rect.top, vw, rect.bottom ) ); split( new Rect( vw, rect.top, rect.right, rect.bottom ) ); } else { - int vh = Random.Int( rect.top + 3, rect.bottom - 3 ); + int vh = Random.Int( rect.top + (minRoomSize/2), rect.bottom - (minRoomSize/2) ); split( new Rect( rect.left, rect.top, rect.right, vh ) ); split( new Rect( rect.left, vh, rect.right, rect.bottom ) ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java index f31b49971..042f63edc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/features/Chasm.java @@ -33,7 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose; import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass; import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java index deb9b9cb0..bcf04c884 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/painters/RegularPainter.java @@ -5,7 +5,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Patch; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MazeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MazeRoom.java index 24ee101e8..6269db3fd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MazeRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MazeRoom.java @@ -26,13 +26,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Random; +//TODO figure out where this should go, tunnel room type perhaps? public class MazeRoom extends Room { - public void paint( Level level, Room room ) { - Painter.fill(level, room, 1, Terrain.EMPTY); + public void paint( Level level ) { + Painter.fill(level, this, 1, Terrain.EMPTY); //true = space, false = wall - boolean[][] maze = new boolean[room.width()][room.height()]; + boolean[][] maze = new boolean[width()][height()]; for (int x = 0; x < maze.length; x++) { for (int y = 0; y < maze[0].length; y++) { @@ -40,8 +41,8 @@ public class MazeRoom extends Room { y == 0 || y == maze[0].length - 1) { //set spaces where there are doors - for (Room.Door d : room.connected.values()) { - if (d.x == x + room.left && d.y == y + room.top) { + for (Door d : connected.values()) { + if (d.x == x + left && d.y == y + top) { maze[x][y] = true; break; } @@ -82,11 +83,11 @@ public class MazeRoom extends Room { } - Painter.fill(level, room, 1, Terrain.EMPTY); + Painter.fill(level, this, 1, Terrain.EMPTY); for (int x = 0; x < maze.length; x++) for (int y = 0; y < maze[0].length; y++) { if (!maze[x][y]) { - Painter.fill(level, x + room.left, y + room.top, 1, 1, Terrain.WALL); + Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL); } } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java index 104dd422f..fff7cff61 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/Room.java @@ -22,6 +22,20 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ArmoryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.CryptRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.GardenRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LaboratoryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LibraryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicWellRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PoolRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StatueRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StorageRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TrapsRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TreasuryRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.VaultRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.Graph; @@ -34,6 +48,8 @@ import java.util.Arrays; import java.util.Collection; import java.util.LinkedHashMap; +//Note that this class should be treated as if it were abstract +// it is currently not abstract to maintain compatibility with pre-0.6.0 saves public class Room extends Rect implements Graph.Node, Bundlable { public ArrayList neigbours = new ArrayList(); @@ -66,6 +82,14 @@ public class Room extends Rect implements Graph.Node, Bundlable { return this; } + public int minDimension(){ + return -1; + } + + public int maxDimension(){ + return -1; + } + //Width and height are increased by 1 because rooms are inclusive to their right and bottom sides @Override public int width() { @@ -82,15 +106,13 @@ public class Room extends Rect implements Graph.Node, Bundlable { return width()*height(); } - public void paint(Level level){ - paint(level, this); - } + public void paint(Level level){ } public void paint(Level level, Room room){ } - private static final ArrayList> ALL_SPEC = new ArrayList<>( Arrays.asList( + private static final ArrayList> ALL_SPEC = new ArrayList<>( Arrays.asList( WeakFloorRoom.class, MagicWellRoom.class, CryptRoom.class, PoolRoom.class, GardenRoom.class, LibraryRoom.class, ArmoryRoom.class, TreasuryRoom.class, TrapsRoom.class, StorageRoom.class, StatueRoom.class, LaboratoryRoom.class, VaultRoom.class ) ); @@ -126,10 +148,6 @@ public class Room extends Rect implements Graph.Node, Bundlable { } } - public Door entrance() { - return connected.values().iterator().next(); - } - public boolean inside( Point p ) { return p.x > left && p.y > top && p.x < right && p.y < bottom; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/AltarRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/AltarRoom.java similarity index 78% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/AltarRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/AltarRoom.java index a79d01223..3b836efd3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/AltarRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/AltarRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; @@ -29,22 +29,22 @@ import com.watabou.utils.Point; //import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.SacrificialFire; -public class AltarRoom extends Room { +public class AltarRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM ); - Point c = room.center(); - Room.Door door = room.entrance(); - if (door.x == room.left || door.x == room.right) { - Point p = Painter.drawInside( level, room, door, Math.abs( door.x - c.x ) - 2, Terrain.EMPTY_SP ); + Point c = center(); + Door door = entrance(); + if (door.x == left || door.x == right) { + Point p = Painter.drawInside( level, this, door, Math.abs( door.x - c.x ) - 2, Terrain.EMPTY_SP ); for (; p.y != c.y; p.y += p.y < c.y ? +1 : -1) { Painter.set( level, p, Terrain.EMPTY_SP ); } } else { - Point p = Painter.drawInside( level, room, door, Math.abs( door.y - c.y ) - 2, Terrain.EMPTY_SP ); + Point p = Painter.drawInside( level, this, door, Math.abs( door.y - c.y ) - 2, Terrain.EMPTY_SP ); for (; p.x != c.x; p.x += p.x < c.x ? +1 : -1) { Painter.set( level, p, Terrain.EMPTY_SP ); } @@ -61,6 +61,6 @@ public class AltarRoom extends Room { fire.seed( c.x + c.y * Level.WIDTH, 5 + Dungeon.depth * 5 ); level.blobs.put( SacrificialFire.class, fire );*/ - door.set( Room.Door.Type.EMPTY ); + door.set( Door.Type.EMPTY ); } } \ No newline at end of file diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ArmoryRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ArmoryRoom.java similarity index 68% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ArmoryRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ArmoryRoom.java index 8dd06ec3d..794e72cae 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ArmoryRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ArmoryRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Bomb; @@ -32,23 +32,23 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class ArmoryRoom extends Room { +public class ArmoryRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Room.Door entrance = room.entrance(); + Door entrance = entrance(); Point statue = null; - if (entrance.x == room.left) { - statue = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 ); - } else if (entrance.x == room.right) { - statue = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 ); - } else if (entrance.y == room.top) { - statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.bottom-1 ); - } else if (entrance.y == room.bottom) { - statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.top+1 ); + if (entrance.x == left) { + statue = new Point( right-1, Random.Int( 2 ) == 0 ? top+1 : bottom-1 ); + } else if (entrance.x == right) { + statue = new Point( left+1, Random.Int( 2 ) == 0 ? top+1 : bottom-1 ); + } else if (entrance.y == top) { + statue = new Point( Random.Int( 2 ) == 0 ? left+1 : right-1, bottom-1 ); + } else if (entrance.y == bottom) { + statue = new Point( Random.Int( 2 ) == 0 ? left+1 : right-1, top+1 ); } if (statue != null) { Painter.set( level, statue, Terrain.STATUE ); @@ -58,12 +58,12 @@ public class ArmoryRoom extends Room { for (int i=0; i < n; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null); level.drop( prize( level ), pos ); } - entrance.set( Room.Door.Type.LOCKED ); + entrance.set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/BlacksmithRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/BlacksmithRoom.java similarity index 75% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/BlacksmithRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/BlacksmithRoom.java index 74e0d9d94..2713e1a55 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/BlacksmithRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/BlacksmithRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -30,18 +30,18 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class BlacksmithRoom extends Room { +public class BlacksmithRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.TRAP ); - Painter.fill( level, room, 2, Terrain.EMPTY_SP ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.TRAP ); + Painter.fill( level, this, 2, Terrain.EMPTY_SP ); for (int i=0; i < 2; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY_SP); level.drop( Generator.random( Random.oneOf( @@ -50,18 +50,18 @@ public class BlacksmithRoom extends Room { ) ), pos ); } - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.UNLOCKED ); - Painter.drawInside( level, room, door, 1, Terrain.EMPTY ); + for (Door door : connected.values()) { + door.set( Door.Type.UNLOCKED ); + Painter.drawInside( level, this, door, 1, Terrain.EMPTY ); } Blacksmith npc = new Blacksmith(); do { - npc.pos = level.pointToCell(room.random( 1 )); + npc.pos = level.pointToCell(random( 1 )); } while (level.heaps.get( npc.pos ) != null); level.mobs.add( npc ); - for(Point p : room.getPoints()) { + for(Point p : getPoints()) { int cell = level.pointToCell(p); if (level.map[cell] == Terrain.TRAP){ level.setTrap(new FireTrap().reveal(), cell); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/CryptRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/CryptRoom.java similarity index 61% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/CryptRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/CryptRoom.java index 7e60161e6..7f191be4c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/CryptRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/CryptRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -32,38 +32,38 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; -public class CryptRoom extends Room { +public class CryptRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Point c = room.center(); + Point c = center(); int cx = c.x; int cy = c.y; - Room.Door entrance = room.entrance(); + Door entrance = entrance(); - entrance.set( Room.Door.Type.LOCKED ); + entrance.set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); - if (entrance.x == room.left) { - Painter.set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE ); - Painter.set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE ); - cx = room.right - 2; - } else if (entrance.x == room.right) { - Painter.set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE ); - Painter.set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE ); - cx = room.left + 2; - } else if (entrance.y == room.top) { - Painter.set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE ); - Painter.set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE ); - cy = room.bottom - 2; - } else if (entrance.y == room.bottom) { - Painter.set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE ); - Painter.set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE ); - cy = room.top + 2; + if (entrance.x == left) { + Painter.set( level, new Point( right-1, top+1 ), Terrain.STATUE ); + Painter.set( level, new Point( right-1, bottom-1 ), Terrain.STATUE ); + cx = right - 2; + } else if (entrance.x == right) { + Painter.set( level, new Point( left+1, top+1 ), Terrain.STATUE ); + Painter.set( level, new Point( left+1, bottom-1 ), Terrain.STATUE ); + cx = left + 2; + } else if (entrance.y == top) { + Painter.set( level, new Point( left+1, bottom-1 ), Terrain.STATUE ); + Painter.set( level, new Point( right-1, bottom-1 ), Terrain.STATUE ); + cy = bottom - 2; + } else if (entrance.y == bottom) { + Painter.set( level, new Point( left+1, top+1 ), Terrain.STATUE ); + Painter.set( level, new Point( right-1, top+1 ), Terrain.STATUE ); + cy = top + 2; } level.drop( prize( level ), cx + cy * level.width() ).type = Heap.Type.TOMB; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/GardenRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java similarity index 71% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/GardenRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java index bc892326f..b0c1309ce 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/GardenRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/GardenRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Challenges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -31,32 +31,32 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush; import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass; import com.watabou.utils.Random; -public class GardenRoom extends Room { +public class GardenRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.HIGH_GRASS ); - Painter.fill( level, room, 2, Terrain.GRASS ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.HIGH_GRASS ); + Painter.fill( level, this, 2, Terrain.GRASS ); - room.entrance().set( Room.Door.Type.REGULAR ); + entrance().set( Door.Type.REGULAR ); if (Dungeon.isChallenged(Challenges.NO_FOOD)) { if (Random.Int(2) == 0){ - level.plant(new Sungrass.Seed(), level.pointToCell(room.random())); + level.plant(new Sungrass.Seed(), level.pointToCell(random())); } } else { int bushes = Random.Int(3); if (bushes == 0) { - level.plant(new Sungrass.Seed(), level.pointToCell(room.random())); + level.plant(new Sungrass.Seed(), level.pointToCell(random())); } else if (bushes == 1) { - level.plant(new BlandfruitBush.Seed(), level.pointToCell(room.random())); + level.plant(new BlandfruitBush.Seed(), level.pointToCell(random())); } else if (Random.Int(5) == 0) { int plant1, plant2; - plant1 = level.pointToCell(room.random()); + plant1 = level.pointToCell(random()); level.plant(new Sungrass.Seed(), plant1); do { - plant2 = level.pointToCell(room.random()); + plant2 = level.pointToCell(random()); } while (plant2 == plant1); level.plant(new BlandfruitBush.Seed(), plant2); } @@ -66,8 +66,8 @@ public class GardenRoom extends Room { if (light == null) { light = new Foliage(); } - for (int i=room.top + 1; i < room.bottom; i++) { - for (int j=room.left + 1; j < room.right; j++) { + for (int i=top + 1; i < bottom; i++) { + for (int j=left + 1; j < right; j++) { light.seed( level, j + level.width() * i, 1 ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LaboratoryRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LaboratoryRoom.java similarity index 70% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LaboratoryRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LaboratoryRoom.java index 1cbcabebb..494c0c44c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LaboratoryRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LaboratoryRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy; @@ -33,24 +33,24 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class LaboratoryRoom extends Room { +public class LaboratoryRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY_SP ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY_SP ); - Room.Door entrance = room.entrance(); + Door entrance = entrance(); Point pot = null; - if (entrance.x == room.left) { - pot = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 ); - } else if (entrance.x == room.right) { - pot = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 ); - } else if (entrance.y == room.top) { - pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 ); - } else if (entrance.y == room.bottom) { - pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 ); + if (entrance.x == left) { + pot = new Point( right-1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 ); + } else if (entrance.x == right) { + pot = new Point( left+1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 ); + } else if (entrance.y == top) { + pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 ); + } else if (entrance.y == bottom) { + pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+1 ); } Painter.set( level, pot, Terrain.ALCHEMY ); @@ -62,14 +62,14 @@ public class LaboratoryRoom extends Room { for (int i=0; i < n; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while ( level.map[pos] != Terrain.EMPTY_SP || level.heaps.get( pos ) != null); level.drop( prize( level ), pos ); } - entrance.set( Room.Door.Type.LOCKED ); + entrance.set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LibraryRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LibraryRoom.java similarity index 82% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LibraryRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LibraryRoom.java index 24435b09e..cdb3504c0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/LibraryRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/LibraryRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -34,19 +34,19 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class LibraryRoom extends Room { +public class LibraryRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY_SP ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY_SP ); - Room.Door entrance = room.entrance(); + Door entrance = entrance(); Point a = null; Point b = null; - Painter.fill( level, room.left + 1, room.top+1, room.width() - 2, 1 , Terrain.BOOKSHELF ); - if (entrance.y == room.top){ + Painter.fill( level, left + 1, top+1, width() - 2, 1 , Terrain.BOOKSHELF ); + if (entrance.y == top){ Painter.set( level, entrance.x, entrance.y + 1, Terrain.EMPTY_SP ); } @@ -54,7 +54,7 @@ public class LibraryRoom extends Room { for (int i=0; i < n; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get( pos ) != null); Item item; if (i == 0) @@ -64,7 +64,7 @@ public class LibraryRoom extends Room { level.drop( item, pos ); } - entrance.set( Room.Door.Type.LOCKED ); + entrance.set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MagicWellRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java similarity index 87% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MagicWellRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java index 55c6a06ce..c75b1c897 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MagicWellRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MagicWellRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -33,17 +33,17 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class MagicWellRoom extends Room { +public class MagicWellRoom extends SpecialRoom { private static final Class[] WATERS = {WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class}; - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Point c = room.center(); + Point c = center(); Painter.set( level, c.x, c.y, Terrain.WELL ); @SuppressWarnings("unchecked") @@ -68,6 +68,6 @@ public class MagicWellRoom extends Room { water.seed( level, c.x + level.width() * c.y, 1 ); level.blobs.put( waterClass, water ); - room.entrance().set( Room.Door.Type.REGULAR ); + entrance().set( Door.Type.REGULAR ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MassGraveRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java similarity index 88% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MassGraveRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java index 37447bb03..fef63a63b 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/MassGraveRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/MassGraveRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Skeleton; @@ -39,20 +39,20 @@ import com.watabou.utils.Random; import java.util.ArrayList; -public class MassGraveRoom extends Room { +public class MassGraveRoom extends SpecialRoom { - public void paint( Level level, Room room){ + public void paint( Level level){ - Room.Door entrance = room.entrance(); - entrance.set(Room.Door.Type.BARRICADE); + Door entrance = entrance(); + entrance.set(Door.Type.BARRICADE); level.addItemToSpawn(new PotionOfLiquidFlame()); - Painter.fill(level, room, Terrain.WALL); - Painter.fill(level, room, 1, Terrain.EMPTY_SP); + Painter.fill(level, this, Terrain.WALL); + Painter.fill(level, this, 1, Terrain.EMPTY_SP); Bones b = new Bones(); - b.setRect(room.left+1, room.top, room.width()-2, room.height()-1); + b.setRect(left+1, top, width()-2, height()-1); level.customTiles.add(b); //50% 1 skeleton, 50% 2 skeletons @@ -61,7 +61,7 @@ public class MassGraveRoom extends Room { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY_SP || level.findMob(pos) != null); skele.pos = pos; level.mobs.add( skele ); @@ -80,7 +80,7 @@ public class MassGraveRoom extends Room { for (Item item : items){ int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null); Heap h = level.drop(item, pos); h.type = Heap.Type.SKELETON; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java similarity index 71% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PitRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java index 66de9bfb3..a2f7b88ae 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PitRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -32,31 +32,31 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class PitRoom extends Room { +public class PitRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Room.Door entrance = room.entrance(); - entrance.set( Room.Door.Type.LOCKED ); + Door entrance = entrance(); + entrance.set( Door.Type.LOCKED ); Point well = null; - if (entrance.x == room.left) { - well = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 ); - } else if (entrance.x == room.right) { - well = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 ); - } else if (entrance.y == room.top) { - well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 ); - } else if (entrance.y == room.bottom) { - well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 ); + if (entrance.x == left) { + well = new Point( right-1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 ); + } else if (entrance.x == right) { + well = new Point( left+1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 ); + } else if (entrance.y == top) { + well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 ); + } else if (entrance.y == bottom) { + well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+1 ); } Painter.set( level, well, Terrain.EMPTY_WELL ); - int remains = level.pointToCell(room.random()); + int remains = level.pointToCell(random()); while (level.map[remains] == Terrain.EMPTY_WELL) { - remains = level.pointToCell(room.random()); + remains = level.pointToCell(random()); } level.drop( new IronKey( Dungeon.depth ), remains ).type = Heap.Type.SKELETON; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PoolRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PoolRoom.java similarity index 78% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PoolRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PoolRoom.java index b6e94babd..db70dc532 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PoolRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/PoolRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha; @@ -33,39 +33,39 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Random; -public class PoolRoom extends Room { +public class PoolRoom extends SpecialRoom { private static final int NPIRANHAS = 3; - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.WATER ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.WATER ); - Room.Door door = room.entrance(); - door.set( Room.Door.Type.REGULAR ); + Door door = entrance(); + door.set( Door.Type.REGULAR ); int x = -1; int y = -1; - if (door.x == room.left) { + if (door.x == left) { - x = room.right - 1; - y = room.top + room.height() / 2; + x = right - 1; + y = top + height() / 2; - } else if (door.x == room.right) { + } else if (door.x == right) { - x = room.left + 1; - y = room.top + room.height() / 2; + x = left + 1; + y = top + height() / 2; - } else if (door.y == room.top) { + } else if (door.y == top) { - x = room.left + room.width() / 2; - y = room.bottom - 1; + x = left + width() / 2; + y = bottom - 1; - } else if (door.y == room.bottom) { + } else if (door.y == bottom) { - x = room.left + room.width() / 2; - y = room.top + 1; + x = left + width() / 2; + y = top + 1; } @@ -79,7 +79,7 @@ public class PoolRoom extends Room { for (int i=0; i < NPIRANHAS; i++) { Piranha piranha = new Piranha(); do { - piranha.pos = level.pointToCell(room.random()); + piranha.pos = level.pointToCell(random()); } while (level.map[piranha.pos] != Terrain.WATER|| level.findMob( piranha.pos ) != null); level.mobs.add( piranha ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RatKingRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RatKingRoom.java similarity index 69% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RatKingRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RatKingRoom.java index f355e9314..4e0c054ee 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RatKingRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RatKingRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.RatKing; import com.shatteredpixel.shatteredpixeldungeon.items.Gold; @@ -30,29 +30,29 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Random; -public class RatKingRoom extends Room { +public class RatKingRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY_SP ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY_SP ); - Room.Door entrance = room.entrance(); - entrance.set( Room.Door.Type.HIDDEN ); + Door entrance = entrance(); + entrance.set( Door.Type.HIDDEN ); int door = entrance.x + entrance.y * level.width(); - for (int i=room.left + 1; i < room.right; i++) { - addChest( level, (room.top + 1) * level.width() + i, door ); - addChest( level, (room.bottom - 1) * level.width() + i, door ); + for (int i=left + 1; i < right; i++) { + addChest( level, (top + 1) * level.width() + i, door ); + addChest( level, (bottom - 1) * level.width() + i, door ); } - for (int i=room.top + 2; i < room.bottom - 1; i++) { - addChest( level, i * level.width() + room.left + 1, door ); - addChest( level, i * level.width() + room.right - 1, door ); + for (int i=top + 2; i < bottom - 1; i++) { + addChest( level, i * level.width() + left + 1, door ); + addChest( level, i * level.width() + right - 1, door ); } RatKing king = new RatKing(); - king.pos = level.pointToCell(room.random( 1 )); + king.pos = level.pointToCell(random( 1 )); level.mobs.add( king ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RotGardenRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java similarity index 73% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RotGardenRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java index e0f1b0953..30412123f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RotGardenRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/RotGardenRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; @@ -32,39 +32,39 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; -public class RotGardenRoom extends Room { +public class RotGardenRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Room.Door entrance = room.entrance(); - entrance.set(Room.Door.Type.LOCKED); + Door entrance = entrance(); + entrance.set(Door.Type.LOCKED); level.addItemToSpawn(new IronKey(Dungeon.depth)); - Painter.fill(level, room, Terrain.WALL); - Painter.fill(level, room, 1, Terrain.GRASS); + Painter.fill(level, this, Terrain.WALL); + Painter.fill(level, this, 1, Terrain.GRASS); - int heartX = Random.IntRange(room.left+1, room.right-1); - int heartY = Random.IntRange(room.top+1, room.bottom-1); + int heartX = Random.IntRange(left+1, right-1); + int heartY = Random.IntRange(top+1, bottom-1); - if (entrance.x == room.left) { - heartX = room.right - 1; - } else if (entrance.x == room.right) { - heartX = room.left + 1; - } else if (entrance.y == room.top) { - heartY = room.bottom - 1; - } else if (entrance.y == room.bottom) { - heartY = room.top + 1; + if (entrance.x == left) { + heartX = right - 1; + } else if (entrance.x == right) { + heartX = left + 1; + } else if (entrance.y == top) { + heartY = bottom - 1; + } else if (entrance.y == bottom) { + heartY = top + 1; } placePlant(level, heartX + heartY * level.width(), new RotHeart()); - int lashers = ((room.width()-2)*(room.height()-2))/8; + int lashers = ((width()-2)*(height()-2))/8; for (int i = 1; i <= lashers; i++){ int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (!validPlantPos(level, pos)); placePlant(level, pos, new RotLasher()); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ShopRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java similarity index 95% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ShopRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java index 51fa2e3c3..66cd9df83 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ShopRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/ShopRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings; @@ -70,6 +70,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.LastShopLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.watabou.utils.PathFinder; import com.watabou.utils.Point; @@ -78,34 +79,34 @@ import com.watabou.utils.Random; import java.util.ArrayList; import java.util.Collections; -public class ShopRoom extends Room { +public class ShopRoom extends SpecialRoom { private static int pasWidth; private static int pasHeight; private static ArrayList itemsToSpawn; - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY_SP ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY_SP ); - pasWidth = room.width() - 3; - pasHeight = room.height() - 3; + pasWidth = width() - 3; + pasHeight = height() - 3; int per = pasWidth * 2 + pasHeight * 2; if (itemsToSpawn == null) generateItems(); - int pos = xy2p( room, room.entrance() ) + (per - itemsToSpawn.size()) / 2; + int pos = xy2p( this, entrance() ) + (per - itemsToSpawn.size()) / 2; for (Item item : itemsToSpawn) { - Point xy = p2xy( room, (pos + per) % per ); + Point xy = p2xy( this, (pos + per) % per ); int cell = xy.x + xy.y * level.width(); if (level.heaps.get( cell ) != null) { do { - cell = level.pointToCell(room.random()); + cell = level.pointToCell(random()); } while (level.heaps.get( cell ) != null); } @@ -114,10 +115,10 @@ public class ShopRoom extends Room { pos++; } - placeShopkeeper( level, room ); + placeShopkeeper( level, this ); - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.REGULAR ); + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); } itemsToSpawn = null; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java new file mode 100644 index 000000000..2c8565b1e --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/SpecialRoom.java @@ -0,0 +1,20 @@ +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; + +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; + +public class SpecialRoom extends Room { + + @Override + public int minDimension() { + return 5; + } + + @Override + public int maxDimension() { + return 10; + } + + public Door entrance() { + return connected.values().iterator().next(); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StatueRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StatueRoom.java similarity index 60% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StatueRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StatueRoom.java index 205964d67..3697c0116 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StatueRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StatueRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue; @@ -29,41 +29,41 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Point; -public class StatueRoom extends Room { +public class StatueRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Point c = room.center(); + Point c = center(); int cx = c.x; int cy = c.y; - Room.Door door = room.entrance(); + Door door = entrance(); - door.set( Room.Door.Type.LOCKED ); + door.set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); - if (door.x == room.left) { + if (door.x == left) { - Painter.fill( level, room.right - 1, room.top + 1, 1, room.height() - 2 , Terrain.STATUE ); - cx = room.right - 2; + Painter.fill( level, right - 1, top + 1, 1, height() - 2 , Terrain.STATUE ); + cx = right - 2; - } else if (door.x == room.right) { + } else if (door.x == right) { - Painter.fill( level, room.left + 1, room.top + 1, 1, room.height() - 2 , Terrain.STATUE ); - cx = room.left + 2; + Painter.fill( level, left + 1, top + 1, 1, height() - 2 , Terrain.STATUE ); + cx = left + 2; - } else if (door.y == room.top) { + } else if (door.y == top) { - Painter.fill( level, room.left + 1, room.bottom - 1, room.width() - 2, 1 , Terrain.STATUE ); - cy = room.bottom - 2; + Painter.fill( level, left + 1, bottom - 1, width() - 2, 1 , Terrain.STATUE ); + cy = bottom - 2; - } else if (door.y == room.bottom) { + } else if (door.y == bottom) { - Painter.fill( level, room.left + 1, room.top + 1, room.width() - 2, 1 , Terrain.STATUE ); - cy = room.top + 2; + Painter.fill( level, left + 1, top + 1, width() - 2, 1 , Terrain.STATUE ); + cy = top + 2; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StorageRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StorageRoom.java similarity index 85% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StorageRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StorageRoom.java index 88e961190..d67850d5a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StorageRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/StorageRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot; @@ -30,14 +30,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Random; -public class StorageRoom extends Room { +public class StorageRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { final int floor = Terrain.EMPTY_SP; - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, floor ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, floor ); boolean honeyPot = Random.Int( 2 ) == 0; @@ -45,7 +45,7 @@ public class StorageRoom extends Room { for (int i=0; i < n; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != floor); if (honeyPot){ level.drop( new Honeypot(), pos); @@ -54,7 +54,7 @@ public class StorageRoom extends Room { level.drop( prize( level ), pos ); } - room.entrance().set( Room.Door.Type.BARRICADE ); + entrance().set( Door.Type.BARRICADE ); level.addItemToSpawn( new PotionOfLiquidFlame() ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TrapsRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TrapsRoom.java similarity index 79% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TrapsRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TrapsRoom.java index 7bfaa6758..7c468078e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TrapsRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TrapsRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; @@ -48,11 +48,11 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class TrapsRoom extends Room { +public class TrapsRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); + Painter.fill( level, this, Terrain.WALL ); Class trapClass; switch (Random.Int(5)){ @@ -68,37 +68,37 @@ public class TrapsRoom extends Room { } if (trapClass == null){ - Painter.fill(level, room, 1, Terrain.CHASM); + Painter.fill(level, this, 1, Terrain.CHASM); } else { - Painter.fill(level, room, 1, Terrain.TRAP); + Painter.fill(level, this, 1, Terrain.TRAP); } - Room.Door door = room.entrance(); - door.set( Room.Door.Type.REGULAR ); + Door door = entrance(); + door.set( Door.Type.REGULAR ); - int lastRow = level.map[room.left + 1 + (room.top + 1) * level.width()] == Terrain.CHASM ? Terrain.CHASM : Terrain.EMPTY; + int lastRow = level.map[left + 1 + (top + 1) * level.width()] == Terrain.CHASM ? Terrain.CHASM : Terrain.EMPTY; int x = -1; int y = -1; - if (door.x == room.left) { - x = room.right - 1; - y = room.top + room.height() / 2; - Painter.fill( level, x, room.top + 1, 1, room.height() - 2 , lastRow ); - } else if (door.x == room.right) { - x = room.left + 1; - y = room.top + room.height() / 2; - Painter.fill( level, x, room.top + 1, 1, room.height() - 2 , lastRow ); - } else if (door.y == room.top) { - x = room.left + room.width() / 2; - y = room.bottom - 1; - Painter.fill( level, room.left + 1, y, room.width() - 2, 1 , lastRow ); - } else if (door.y == room.bottom) { - x = room.left + room.width() / 2; - y = room.top + 1; - Painter.fill( level, room.left + 1, y, room.width() - 2, 1 , lastRow ); + if (door.x == left) { + x = right - 1; + y = top + height() / 2; + Painter.fill( level, x, top + 1, 1, height() - 2 , lastRow ); + } else if (door.x == right) { + x = left + 1; + y = top + height() / 2; + Painter.fill( level, x, top + 1, 1, height() - 2 , lastRow ); + } else if (door.y == top) { + x = left + width() / 2; + y = bottom - 1; + Painter.fill( level, left + 1, y, width() - 2, 1 , lastRow ); + } else if (door.y == bottom) { + x = left + width() / 2; + y = top + 1; + Painter.fill( level, left + 1, y, width() - 2, 1 , lastRow ); } - for(Point p : room.getPoints()) { + for(Point p : getPoints()) { int cell = level.pointToCell(p); if (level.map[cell] == Terrain.TRAP){ try { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TreasuryRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TreasuryRoom.java similarity index 81% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TreasuryRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TreasuryRoom.java index 2b82d7d85..d8ea70c13 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TreasuryRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/TreasuryRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Gold; @@ -30,14 +30,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.Random; -public class TreasuryRoom extends Room { +public class TreasuryRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - Painter.set( level, room.center(), Terrain.STATUE ); + Painter.set( level, center(), Terrain.STATUE ); Heap.Type heapType = Random.Int( 2 ) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP; @@ -45,7 +45,7 @@ public class TreasuryRoom extends Room { for (int i=0; i < n; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null); level.drop( new Gold().random(), pos ).type = (Random.Int(20) == 0 && heapType == Heap.Type.CHEST ? Heap.Type.MIMIC : heapType); } @@ -54,13 +54,13 @@ public class TreasuryRoom extends Room { for (int i=0; i < 6; i++) { int pos; do { - pos = level.pointToCell(room.random()); + pos = level.pointToCell(random()); } while (level.map[pos] != Terrain.EMPTY); level.drop( new Gold( Random.IntRange( 5, 12 ) ), pos ); } } - room.entrance().set( Room.Door.Type.LOCKED ); + entrance().set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/VaultRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/VaultRoom.java similarity index 84% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/VaultRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/VaultRoom.java index 4d8d9e6eb..8b2f2186e 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/VaultRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/VaultRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -33,16 +33,16 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; -public class VaultRoom extends Room { +public class VaultRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY_SP ); - Painter.fill( level, room, 2, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY_SP ); + Painter.fill( level, this, 2, Terrain.EMPTY ); - int cx = (room.left + room.right) / 2; - int cy = (room.top + room.bottom) / 2; + int cx = (left + right) / 2; + int cy = (top + bottom) / 2; int c = cx + cy * level.width(); switch (Random.Int( 3 )) { @@ -69,7 +69,7 @@ public class VaultRoom extends Room { break; } - room.entrance().set( Room.Door.Type.LOCKED ); + entrance().set( Door.Type.LOCKED ); level.addItemToSpawn( new IronKey( Dungeon.depth ) ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/WeakFloorRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/WeakFloorRoom.java similarity index 54% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/WeakFloorRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/WeakFloorRoom.java index 2ae3e1699..b563b4381 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/WeakFloorRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/special/WeakFloorRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; @@ -31,43 +31,43 @@ import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual; import com.watabou.utils.Point; import com.watabou.utils.Random; -public class WeakFloorRoom extends Room { +public class WeakFloorRoom extends SpecialRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.CHASM ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.CHASM ); - Room.Door door = room.entrance(); - door.set( Room.Door.Type.REGULAR ); + Door door = entrance(); + door.set( Door.Type.REGULAR ); - if (door.x == room.left) { - for (int i=room.top + 1; i < room.bottom; i++) { - Painter.drawInside( level, room, new Point( room.left, i ), Random.IntRange( 1, room.width() - 3 ), Terrain.EMPTY_SP ); + if (door.x == left) { + for (int i=top + 1; i < bottom; i++) { + Painter.drawInside( level, this, new Point( left, i ), Random.IntRange( 1, width() - 3 ), Terrain.EMPTY_SP ); } - } else if (door.x == room.right) { - for (int i=room.top + 1; i < room.bottom; i++) { - Painter.drawInside( level, room, new Point( room.right, i ), Random.IntRange( 1, room.width() - 3 ), Terrain.EMPTY_SP ); + } else if (door.x == right) { + for (int i=top + 1; i < bottom; i++) { + Painter.drawInside( level, this, new Point( right, i ), Random.IntRange( 1, width() - 3 ), Terrain.EMPTY_SP ); } - } else if (door.y == room.top) { - for (int i=room.left + 1; i < room.right; i++) { - Painter.drawInside( level, room, new Point( i, room.top ), Random.IntRange( 1, room.height() - 3 ), Terrain.EMPTY_SP ); + } else if (door.y == top) { + for (int i=left + 1; i < right; i++) { + Painter.drawInside( level, this, new Point( i, top ), Random.IntRange( 1, height() - 3 ), Terrain.EMPTY_SP ); } - } else if (door.y == room.bottom) { - for (int i=room.left + 1; i < room.right; i++) { - Painter.drawInside( level, room, new Point( i, room.bottom ), Random.IntRange( 1, room.height() - 3 ), Terrain.EMPTY_SP ); + } else if (door.y == bottom) { + for (int i=left + 1; i < right; i++) { + Painter.drawInside( level, this, new Point( i, bottom ), Random.IntRange( 1, height() - 3 ), Terrain.EMPTY_SP ); } } Point well = null; - if (door.x == room.left) { - well = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 2 : room.bottom - 1 ); - } else if (door.x == room.right) { - well = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 2 : room.bottom - 1 ); - } else if (door.y == room.top) { - well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 ); - } else if (door.y == room.bottom) { - well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+2 ); + if (door.x == left) { + well = new Point( right-1, Random.Int( 2 ) == 0 ? top + 2 : bottom - 1 ); + } else if (door.x == right) { + well = new Point( left+1, Random.Int( 2 ) == 0 ? top + 2 : bottom - 1 ); + } else if (door.y == top) { + well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 ); + } else if (door.y == bottom) { + well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+2 ); } Painter.set(level, well, Terrain.CHASM); CustomTiledVisual vis = new HiddenWell(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/EntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java similarity index 73% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/EntranceRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java index 94c5ced78..ceda85155 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/EntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/EntranceRoom.java @@ -19,25 +19,26 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -public class EntranceRoom extends Room { +public class EntranceRoom extends StandardRoom { - public void paint( Level level, Room room ) { + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - for (Room.Door door : room.connected.values()) { + for (Room.Door door : connected.values()) { door.set( Room.Door.Type.REGULAR ); } do { - level.entrance = level.pointToCell(room.random(1)); + level.entrance = level.pointToCell(random(1)); } while (level.findMob(level.entrance) != null); Painter.set( level, level.entrance, Terrain.ENTRANCE ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java similarity index 72% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ExitRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java index dfd83188c..8ceda38c7 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/ExitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ExitRoom.java @@ -19,24 +19,25 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; -public class ExitRoom extends Room { +public class ExitRoom extends StandardRoom { - public void paint( Level level, Room room ) { + public void paint( Level level) { - Painter.fill( level, room, Terrain.WALL ); - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1, Terrain.EMPTY ); - for (Room.Door door : room.connected.values()) { + for (Room.Door door : connected.values()) { door.set( Room.Door.Type.REGULAR ); } - level.exit = level.pointToCell(room.random( 1 )); + level.exit = level.pointToCell(random( 1 )); Painter.set( level, level.exit, Terrain.EXIT ); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RitualSiteRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java similarity index 85% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RitualSiteRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java index a492df284..88fd4bd6f 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/RitualSiteRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/RitualSiteRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle; @@ -30,19 +30,19 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual; import com.watabou.utils.Point; -public class RitualSiteRoom extends Room { +public class RitualSiteRoom extends StandardRoom { - public void paint( Level level, Room room) { + public void paint( Level level ) { - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.REGULAR ); + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); } - Painter.fill(level, room, Terrain.WALL); - Painter.fill(level, room, 1, Terrain.EMPTY); + Painter.fill(level, this, Terrain.WALL); + Painter.fill(level, this, 1, Terrain.EMPTY); RitualMarker vis = new RitualMarker(); - Point c = room.center(); + Point c = center(); vis.pos(c.x - 1, c.y - 1); level.customTiles.add(vis); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java similarity index 89% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StandardRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index c8abd6855..11bd21057 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -19,7 +19,7 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; @@ -29,25 +29,36 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap; import com.watabou.utils.Point; import com.watabou.utils.Random; public class StandardRoom extends Room { - - public void paint( Level level, Room room ) { + + @Override + public int minDimension() { + return 4; + } + + @Override + public int maxDimension() { + return 10; + } + + public void paint( Level level ) { - Painter.fill( level, room, Terrain.WALL ); - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.REGULAR ); + Painter.fill( level, this, Terrain.WALL ); + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); } if (!Dungeon.bossLevel() && Random.Int( 5 ) == 0) { switch (Random.Int( 6 )) { case 0: if (level.feeling != Level.Feeling.GRASS) { - if (Math.min( room.width(), room.height() ) > 4 && Math.max( room.width(), room.height() ) > 6) { - paintGraveyard( level, room ); + if (Math.min( width(), height() ) > 4 && Math.max( width(), height() ) > 6) { + paintGraveyard( level, this ); return; } break; @@ -56,26 +67,26 @@ public class StandardRoom extends Room { } case 1: if (Dungeon.depth > 1) { - paintBurned( level, room ); + paintBurned( level, this ); return; } break; case 2: - if (Math.max( room.width(), room.height() ) > 4) { - paintStriped( level, room ); + if (Math.max( width(), height() ) > 4) { + paintStriped( level, this ); return; } break; case 3: - if (room.width() > 6 && room.height() > 6) { - paintStudy( level, room ); + if (width() > 6 && height() > 6) { + paintStudy( level, this ); return; } break; case 4: if (level.feeling != Level.Feeling.WATER) { - if (room.connected.size() == 2 && room.width() > 4 && room.height() > 4) { - paintBridge( level, room ); + if (connected.size() == 2 && width() > 4 && height() > 4) { + paintBridge( level, this ); return; } break; @@ -84,15 +95,15 @@ public class StandardRoom extends Room { } case 5: if (!Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) && - Math.min( room.width(), room.height() ) > 5) { - paintFissure( level, room ); + Math.min( width(), height() ) > 5) { + paintFissure( level, this ); return; } break; } } - Painter.fill( level, room, 1, Terrain.EMPTY ); + Painter.fill( level, this, 1, Terrain.EMPTY ); } private static void paintBurned( Level level, Room room ) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PassageRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/PassageRoom.java similarity index 83% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PassageRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/PassageRoom.java index 08e2a75e8..f03a03047 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/PassageRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/PassageRoom.java @@ -19,30 +19,31 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.watabou.utils.Point; import java.util.ArrayList; import java.util.Collections; -public class PassageRoom extends Room { +public class PassageRoom extends TunnelRoom { private static int pasWidth; private static int pasHeight; - public void paint( Level level, Room room ) { + public void paint( Level level ) { - pasWidth = room.width() - 3; - pasHeight = room.height() - 3; + pasWidth = width() - 3; + pasHeight = height() - 3; int floor = level.tunnelTile(); ArrayList joints = new ArrayList(); - for (Point door : room.connected.values()) { - joints.add( xy2p( room, door ) ); + for (Point door : connected.values()) { + joints.add( xy2p( this, door ) ); } Collections.sort( joints ); @@ -63,14 +64,14 @@ public class PassageRoom extends Room { int p = joints.get( start ); do { - Painter.set( level, p2xy( room, p ), floor ); + Painter.set( level, p2xy( this, p ), floor ); p = (p + 1) % perimeter; } while (p != joints.get( end )); - Painter.set( level, p2xy( room, p ), floor ); + Painter.set( level, p2xy( this, p ), floor ); - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.TUNNEL ); + for (Door door : connected.values()) { + door.set( Door.Type.TUNNEL ); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TunnelRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java similarity index 73% rename from core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TunnelRoom.java rename to core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java index ddab8b902..299ac3c25 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/TunnelRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/tunnel/TunnelRoom.java @@ -19,40 +19,51 @@ * along with this program. If not, see */ -package com.shatteredpixel.shatteredpixeldungeon.levels.rooms; +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.watabou.utils.Point; import com.watabou.utils.Random; public class TunnelRoom extends Room { - - public void paint( Level level, Room room ) { + + @Override + public int minDimension() { + return 3; + } + + @Override + public int maxDimension() { + return 10; + } + + public void paint(Level level) { int floor = level.tunnelTile(); - Point c = room.center(); + Point c = center(); - if (room.width() > room.height() || (room.width() == room.height() && Random.Int( 2 ) == 0)) { + if (width() > height() || (width() == height() && Random.Int( 2 ) == 0)) { - int from = room.right - 1; - int to = room.left + 1; + int from = right - 1; + int to = left + 1; - for (Room.Door door : room.connected.values()) { + for (Door door : connected.values()) { int step = door.y < c.y ? +1 : -1; - if (door.x == room.left) { + if (door.x == left) { - from = room.left + 1; + from = left + 1; for (int i=door.y; i != c.y; i += step) { Painter.set( level, from, i, floor ); } - } else if (door.x == room.right) { + } else if (door.x == right) { - to = room.right - 1; + to = right - 1; for (int i=door.y; i != c.y; i += step) { Painter.set( level, to, i, floor ); } @@ -77,23 +88,23 @@ public class TunnelRoom extends Room { } else { - int from = room.bottom - 1; - int to = room.top + 1; + int from = bottom - 1; + int to = top + 1; - for (Room.Door door : room.connected.values()) { + for (Door door : connected.values()) { int step = door.x < c.x ? +1 : -1; - if (door.y == room.top) { + if (door.y == top) { - from = room.top + 1; + from = top + 1; for (int i=door.x; i != c.x; i += step) { Painter.set( level, i, from, floor ); } - } else if (door.y == room.bottom) { + } else if (door.y == bottom) { - to = room.bottom - 1; + to = bottom - 1; for (int i=door.x; i != c.x; i += step) { Painter.set( level, i, to, floor ); } @@ -117,8 +128,8 @@ public class TunnelRoom extends Room { } } - for (Room.Door door : room.connected.values()) { - door.set( Room.Door.Type.TUNNEL ); + for (Door door : connected.values()) { + door.set( Door.Type.TUNNEL ); } } }