From 5c0648dcf2157fc4a9d284790450cd49b8b3358d Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 24 Jul 2017 14:32:31 -0400 Subject: [PATCH] v0.6.1: added a new type of connection room (and chasm variant) --- .../levels/rooms/connection/BridgeRoom.java | 2 +- .../rooms/connection/ConnectionRoom.java | 15 ++-- .../rooms/connection/RingBridgeRoom.java | 52 +++++++++++++ .../rooms/connection/RingTunnelRoom.java | 73 +++++++++++++++++++ .../levels/rooms/connection/WalkwayRoom.java | 2 +- 5 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingBridgeRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingTunnelRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/BridgeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/BridgeRoom.java index 41e882019..08d617a5a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/BridgeRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/BridgeRoom.java @@ -39,7 +39,7 @@ public class BridgeRoom extends TunnelRoom { super.paint(level); for (Room r : neigbours){ - if (r instanceof BridgeRoom || r instanceof WalkwayRoom){ + if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java index 50fff1ecb..0a63d045d 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/ConnectionRoom.java @@ -66,27 +66,28 @@ public abstract class ConnectionRoom extends Room { rooms.add(PerimeterRoom.class); rooms.add(WalkwayRoom.class); - rooms.add(MazeConnectionRoom.class); + rooms.add(RingTunnelRoom.class); + rooms.add(RingBridgeRoom.class); } private static float[][] chances = new float[27][]; static { - chances[1] = new float[]{10, 1, 0, 1, 0}; + chances[1] = new float[]{20, 1, 0, 2, 2, 1}; chances[4] = chances[3] = chances[2] = chances[1]; - chances[5] = new float[]{1, 0, 0, 0, 0}; + chances[5] = new float[]{18, 0, 0, 0, 7, 0}; - chances[6] = new float[]{0, 0, 10, 2, 0}; + chances[6] = new float[]{0, 0, 22, 3, 0, 0}; chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; - chances[11] = new float[]{10, 0, 0, 5, 0}; + chances[11] = new float[]{12, 0, 0, 5, 5, 3}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; - chances[16] = new float[]{0, 1, 10, 1, 0}; + chances[16] = new float[]{0, 0, 18, 3, 3, 1}; chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; chances[21] = chances[5]; - chances[22] = new float[]{10, 3, 0, 2, 0}; + chances[22] = new float[]{15, 4, 0, 2, 3, 2}; chances[26] = chances[25] = chances[24] = chances[23] = chances[22]; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingBridgeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingBridgeRoom.java new file mode 100644 index 000000000..2242f8eff --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingBridgeRoom.java @@ -0,0 +1,52 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2017 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection; + +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.watabou.utils.Rect; + +public class RingBridgeRoom extends RingTunnelRoom { + + @Override + public void paint(Level level) { + Painter.fill(level, this, 1, Terrain.CHASM); + + super.paint(level); + + for (Room r : neigbours){ + if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ + Rect i = intersect(r); + if (i.width() != 0){ + i.left++; + i.right--; + } else { + i.top++; + i.bottom--; + } + Painter.fill(level, i.left, i.top, i.width()+1, i.height()+1, Terrain.CHASM); + } + } + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingTunnelRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingTunnelRoom.java new file mode 100644 index 000000000..803d373d3 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/RingTunnelRoom.java @@ -0,0 +1,73 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2017 Evan Debenham + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see + */ + +package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.connection; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.watabou.utils.GameMath; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; +import com.watabou.utils.Rect; + +public class RingTunnelRoom extends TunnelRoom { + + @Override + public int minWidth() { + return Math.max(5, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(5, super.minHeight()); + } + + @Override + public void paint(Level level) { + super.paint(level); + + int floor = level.tunnelTile(); + + Rect ring = getConnectionSpace(); + + Painter.fill( level, ring.left, ring.top, 3, 3, floor); + Painter.fill( level, ring.left+1, ring.top+1, 1, 1, Terrain.WALL); + } + + //caches the value so multiple calls will always return the same. + private Rect connSpace; + + @Override + protected Rect getConnectionSpace() { + if (connSpace == null) { + Point c = getDoorCenter(); + + c.x = (int) GameMath.gate(left + 2, c.x, right - 2); + c.y = (int) GameMath.gate(top + 2, c.y, bottom - 2); + + + connSpace = new Rect(c.x-1, c.y-1, c.x+1, c.y+1); + } + + return connSpace; + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/WalkwayRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/WalkwayRoom.java index 3e51842ee..f09abb7b3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/WalkwayRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/connection/WalkwayRoom.java @@ -39,7 +39,7 @@ public class WalkwayRoom extends PerimeterRoom { super.paint(level); for (Room r : neigbours){ - if (r instanceof BridgeRoom || r instanceof WalkwayRoom){ + if (r instanceof BridgeRoom || r instanceof RingBridgeRoom || r instanceof WalkwayRoom){ Rect i = intersect(r); if (i.width() != 0){ i.left++;