From 193633b6028ff6de63ab158898970c10976df521 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Sun, 30 Jul 2017 22:29:33 -0400 Subject: [PATCH] v0.6.1: Added 5 new regional rooms, and adjusted room spawn rates --- .../levels/rooms/standard/CirclePitRoom.java | 41 +++++ .../levels/rooms/standard/HallwayRoom.java | 120 ++++++++++++++ .../levels/rooms/standard/SewerPipeRoom.java | 151 ++++++++++++++++++ .../levels/rooms/standard/SkullsRoom.java | 87 ++++++++++ .../levels/rooms/standard/StandardRoom.java | 31 ++-- .../levels/rooms/standard/StatuesRoom.java | 79 +++++++++ 6 files changed, 499 insertions(+), 10 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/HallwayRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SewerPipeRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SkullsRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StatuesRoom.java diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java new file mode 100644 index 000000000..9915de45c --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/CirclePitRoom.java @@ -0,0 +1,41 @@ +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; + +public class CirclePitRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(8, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(8, super.minHeight()); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{4, 2, 1}; + } + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + + Painter.fillEllipse( level, this, 1 , Terrain.EMPTY ); + + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); + if (door.x == left || door.x == right){ + Painter.drawInside(level, this, door, width()/2, Terrain.EMPTY); + } else { + Painter.drawInside(level, this, door, height()/2, Terrain.EMPTY); + } + } + + Painter.fillEllipse( level, this, 3 , Terrain.CHASM ); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/HallwayRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/HallwayRoom.java new file mode 100644 index 000000000..4f325f04d --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/HallwayRoom.java @@ -0,0 +1,120 @@ +/* + * 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.standard; + +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.Point; +import com.watabou.utils.PointF; +import com.watabou.utils.Random; +import com.watabou.utils.Rect; + +public class HallwayRoom extends EmptyRoom { + + //FIXME lots of copy-pasta from tunnel rooms here + @Override + public void paint(Level level) { + + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1 , Terrain.EMPTY ); + + if (connected.size() < 2){ + //don't want to make a hallway between doors that don't exist + return; + } + + + Rect c = getConnectionSpace(); + + for (Door door : connected.values()) { + + Point start; + Point mid; + Point end; + + start = new Point(door); + if (start.x == left) start.x++; + else if (start.y == top) start.y++; + else if (start.x == right) start.x--; + else if (start.y == bottom) start.y--; + + int rightShift; + int downShift; + + if (start.x < c.left) rightShift = c.left - start.x; + else if (start.x > c.right) rightShift = c.right - start.x; + else rightShift = 0; + + if (start.y < c.top) downShift = c.top - start.y; + else if (start.y > c.bottom) downShift = c.bottom - start.y; + else downShift = 0; + + //always goes inward first + if (door.x == left || door.x == right){ + mid = new Point(start.x + rightShift, start.y); + end = new Point(mid.x, mid.y + downShift); + + } else { + mid = new Point(start.x, start.y + downShift); + end = new Point(mid.x + rightShift, mid.y); + + } + + Painter.drawLine( level, start, mid, Terrain.EMPTY_SP ); + Painter.drawLine( level, mid, end, Terrain.EMPTY_SP ); + + } + + for (Door door : connected.values()) { + door.set( Door.Type.UNLOCKED ); + } + } + + //returns the space which all doors must connect to (usually 1 cell, but can be more) + //Note that, like rooms, this space is inclusive to its right and bottom sides + protected Rect getConnectionSpace(){ + Point c = connected.size() <= 1 ? center() : getDoorCenter(); + + return new Rect(c.x, c.y, c.x, c.y); + } + + //returns a point equidistant from all doors this room has + protected final Point getDoorCenter(){ + PointF doorCenter = new PointF(0, 0); + + for (Door door : connected.values()) { + doorCenter.x += door.x; + doorCenter.y += door.y; + } + + Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); + if (Random.Float() < doorCenter.x % 1) c.x++; + if (Random.Float() < doorCenter.y % 1) c.y++; + c.x = (int) GameMath.gate(left+2, c.x, right-2); + c.y = (int)GameMath.gate(top+2, c.y, bottom-2); + + return c; + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SewerPipeRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SewerPipeRoom.java new file mode 100644 index 000000000..adec93c53 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SewerPipeRoom.java @@ -0,0 +1,151 @@ +/* + * 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.standard; + +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.PointF; +import com.watabou.utils.Random; +import com.watabou.utils.Rect; + +public class SewerPipeRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(7, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(7, super.minHeight()); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{4, 2, 1}; + } + + @Override + public boolean canConnect(Point p) { + //refuses connections next to corners + return super.canConnect(p) && ((p.x > left+1 && p.x < right-1) || (p.y > top+1 && p.y < bottom-1)); + } + + //FIXME lots of copy-pasta from tunnel rooms here + @Override + public void paint(Level level) { + + Painter.fill( level, this, Terrain.WALL ); + + Rect c = getConnectionSpace(); + + for (Door door : connected.values()) { + + Point start; + Point mid; + Point end; + + start = new Point(door); + if (start.x == left) start.x+=2; + else if (start.y == top) start.y+=2; + else if (start.x == right) start.x-=2; + else if (start.y == bottom) start.y-=2; + + int rightShift; + int downShift; + + if (start.x < c.left) rightShift = c.left - start.x; + else if (start.x > c.right) rightShift = c.right - start.x; + else rightShift = 0; + + if (start.y < c.top) downShift = c.top - start.y; + else if (start.y > c.bottom) downShift = c.bottom - start.y; + else downShift = 0; + + //always goes inward first + if (door.x == left || door.x == right){ + mid = new Point(start.x + rightShift, start.y); + end = new Point(mid.x, mid.y + downShift); + + } else { + mid = new Point(start.x, start.y + downShift); + end = new Point(mid.x + rightShift, mid.y); + + } + + Painter.drawLine( level, start, mid, Terrain.WATER); + Painter.drawLine( level, mid, end, Terrain.WATER ); + + } + + for(Point p : getPoints()){ + int cell = level.pointToCell(p); + if (level.map[cell] == Terrain.WATER){ + for (int i : PathFinder.NEIGHBOURS8){ + if (level.map[cell + i] == Terrain.WALL){ + Painter.set(level, cell + i, Terrain.EMPTY); + } + } + } + } + + for (Door door : connected.values()) { + door.set( Door.Type.UNLOCKED ); + } + } + + //returns the space which all doors must connect to (usually 1 cell, but can be more) + //Note that, like rooms, this space is inclusive to its right and bottom sides + protected Rect getConnectionSpace(){ + Point c = connected.size() <= 1 ? center() : getDoorCenter(); + + return new Rect(c.x, c.y, c.x, c.y); + } + + @Override + public boolean canPlaceWater(Point p) { + return false; + } + + //returns a point equidistant from all doors this room has + protected final Point getDoorCenter(){ + PointF doorCenter = new PointF(0, 0); + + for (Door door : connected.values()) { + doorCenter.x += door.x; + doorCenter.y += door.y; + } + + Point c = new Point((int)doorCenter.x / connected.size(), (int)doorCenter.y / connected.size()); + if (Random.Float() < doorCenter.x % 1) c.x++; + if (Random.Float() < doorCenter.y % 1) c.y++; + c.x = (int) GameMath.gate(left+2, c.x, right-2); + c.y = (int)GameMath.gate(top+2, c.y, bottom-2); + + return c; + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SkullsRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SkullsRoom.java new file mode 100644 index 000000000..34811aee6 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/SkullsRoom.java @@ -0,0 +1,87 @@ +/* + * 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.standard; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; + +public class SkullsRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(7, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(7, super.minHeight()); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{9, 3, 1}; + } + + @Override + public void paint(Level level) { + + int minDim = Math.min(width(), height()); + + Painter.fill( level, this, Terrain.WALL ); + + if (minDim >= 9) { + Painter.fillEllipse(level, this, 2, Terrain.EMPTY); + } else { + Painter.fill(level, this, 2, Terrain.EMPTY); + } + + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); + if (door.x == left || door.x == right){ + Painter.drawInside(level, this, door, (width() - 3) / 2, Terrain.EMPTY); + } else { + Painter.drawInside(level, this, door, (height() - 3) / 2, Terrain.EMPTY); + } + } + + boolean oddWidth = width() % 2 == 1; + boolean oddHeight = height() % 2 == 1; + + if (minDim >= 12){ + + Painter.fillEllipse(level, this, 5, Terrain.STATUE); + Painter.fillEllipse(level, this, 6, Terrain.WALL); + + } else { + + Painter.fill(level, + left + width()/2 + (oddWidth ? 0 : -1), + top + height()/2 + (oddHeight ? 0 : -1), + oddWidth ? 1 : 2, + oddHeight ? 1 : 2, + Terrain.STATUE); + + } + + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java index d9164c3d8..a5266fa54 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StandardRoom.java @@ -114,13 +114,24 @@ public abstract class StandardRoom extends Room { private static ArrayList> rooms = new ArrayList<>(); static { rooms.add(EmptyRoom.class); - + + + rooms.add(SewerPipeRoom.class); rooms.add(RingRoom.class); + rooms.add(SegmentedRoom.class); + rooms.add(StatuesRoom.class); + rooms.add(CaveRoom.class); + rooms.add(CirclePitRoom.class); + + rooms.add(HallwayRoom.class); rooms.add(PillarsRoom.class); + rooms.add(RuinsRoom.class); - + rooms.add(SkullsRoom.class); + + rooms.add(GardenRoom.class); rooms.add(AquariumRoom.class); rooms.add(PlatformRoom.class); @@ -135,23 +146,23 @@ public abstract class StandardRoom extends Room { private static float[][] chances = new float[27][]; static { - chances[1] = new float[]{25, 15, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0}; - chances[2] = new float[]{25, 15, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + chances[1] = new float[]{20, 15,5, 0,0, 0,0, 0,0, 0,0, 1,0,1,0,1,0,1,1,0,0}; + chances[2] = new float[]{20, 15,5, 0,0, 0,0, 0,0, 0,0, 1,1,1,1,1,1,1,1,1,1}; chances[4] = chances[3] = chances[2]; - chances[5] = new float[]{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; + chances[5] = new float[]{50, 0,0, 0,0, 0,0, 0,0, 0,0, 0,0,0,0,0,0,0,0,0,0}; - chances[6] = new float[]{25, 0, 15, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + chances[6] = new float[]{20, 0,0, 15,5, 0,0, 0,0, 0,0, 1,1,1,1,1,1,1,1,1,1}; chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; - chances[11] = new float[]{25, 0, 0, 15, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + chances[11] = new float[]{20, 0,0, 0,0, 15,5, 0,0, 0,0, 1,1,1,1,1,1,1,1,1,1}; chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; - - chances[16] = new float[]{25, 0, 0, 0, 15, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + + chances[16] = new float[]{20, 0,0, 0,0, 0,0, 15,5, 0,0, 1,1,1,1,1,1,1,1,1,1}; chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; chances[21] = chances[5]; - chances[22] = new float[]{25, 0, 0, 0, 0, 15, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + chances[22] = new float[]{20, 0,0, 0,0, 0,0, 0,0, 15,5, 1,1,1,1,1,1,1,1,1,1}; chances[26] = chances[25] = chances[24] = chances[23] = chances[22]; } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StatuesRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StatuesRoom.java new file mode 100644 index 000000000..be413fa4d --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/StatuesRoom.java @@ -0,0 +1,79 @@ +/* + * 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.standard; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; + +public class StatuesRoom extends StandardRoom { + + @Override + public int minWidth() { + return Math.max(7, super.minWidth()); + } + + @Override + public int minHeight() { + return Math.max(7, super.minHeight()); + } + + @Override + public float[] sizeCatProbs() { + return new float[]{9, 3, 1}; + } + + @Override + public void paint(Level level) { + Painter.fill( level, this, Terrain.WALL ); + Painter.fill( level, this, 1 , Terrain.EMPTY ); + + for (Door door : connected.values()) { + door.set( Door.Type.REGULAR ); + } + + + int rows = (width() + 1)/6; + int cols = (height() + 1)/6; + + int w = (width() - 4 - (rows-1))/rows; + int h = (height() - 4 - (cols-1))/cols; + + int Wspacing = rows % 2 == width() % 2 ? 2 : 1; + int Hspacing = cols % 2 == height() % 2 ? 2 : 1; + + for (int x = 0; x < rows; x++){ + for (int y = 0; y < cols; y++){ + int left = this.left + 2 + (x * (w + Wspacing)); + int top = this.top + 2 + (y * (h + Hspacing)); + + Painter.fill(level, left, top, w, h, Terrain.EMPTY_SP); + + Painter.set(level, left, top, Terrain.STATUE_SP); + Painter.set(level, left + w-1, top, Terrain.STATUE_SP); + Painter.set(level, left, top + h-1, Terrain.STATUE_SP); + Painter.set(level, left + w-1, top + h-1, Terrain.STATUE_SP); + } + } + + } +}