From 7e256333f4751f61910117b190fb3f04ba0cd092 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 18 Apr 2024 10:07:14 -0400 Subject: [PATCH] v2.4.0: added an entrance/exit variant for each region --- .../levels/RegularLevel.java | 4 +- .../levels/rooms/quest/MineEntrance.java | 3 +- .../levels/rooms/standard/ChasmRoom.java | 10 +++ .../standard/entrance/CaveEntranceRoom.java | 69 +++++++++++++++++ .../standard/entrance/ChasmEntranceRoom.java | 61 +++++++++++++++ .../entrance/CircleBasinEntranceRoom.java | 59 +++++++++++++++ .../rooms/standard/entrance/EntranceRoom.java | 45 ++++++++++- .../entrance/HallwayEntranceRoom.java | 53 +++++++++++++ .../entrance/PillarsEntranceRoom.java | 65 ++++++++++++++++ .../rooms/standard/exit/CaveExitRoom.java | 74 +++++++++++++++++++ .../rooms/standard/exit/ChasmExitRoom.java | 61 +++++++++++++++ .../standard/exit/CircleBasinExitRoom.java | 60 +++++++++++++++ .../levels/rooms/standard/exit/ExitRoom.java | 43 +++++++++++ .../rooms/standard/exit/HallwayExitRoom.java | 54 ++++++++++++++ .../rooms/standard/exit/PillarsExitRoom.java | 66 +++++++++++++++++ 15 files changed, 723 insertions(+), 4 deletions(-) create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CaveEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/ChasmEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CircleBasinEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/HallwayEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/PillarsEntranceRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CaveExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ChasmExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleBasinExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/HallwayExitRoom.java create mode 100644 core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/PillarsExitRoom.java 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 9241e1881..e52233b28 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/RegularLevel.java @@ -114,8 +114,8 @@ public abstract class RegularLevel extends Level { protected ArrayList initRooms() { ArrayList initRooms = new ArrayList<>(); - initRooms.add ( roomEntrance = new EntranceRoom()); - initRooms.add( roomExit = new ExitRoom()); + initRooms.add ( roomEntrance = EntranceRoom.createEntrance()); + initRooms.add( roomExit = ExitRoom.createExit()); //force max standard rooms and multiple by 1.5x for large levels int standards = standardRooms(feeling == Feeling.LARGE); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java index 554ed0777..6ac2c96cb 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/quest/MineEntrance.java @@ -69,8 +69,9 @@ public class MineEntrance extends CaveRoom { super.paint(level); int entrance; - boolean valid = false; + boolean valid; do { + valid = false; entrance = level.pointToCell(random(3)); for (int i : PathFinder.NEIGHBOURS9){ if (level.map[entrance+i] != Terrain.WALL){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ChasmRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ChasmRoom.java index 4d93d8cdd..2dccd21f8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ChasmRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ChasmRoom.java @@ -34,6 +34,16 @@ public class ChasmRoom extends PatchRoom { return new float[]{4, 2, 1}; } + @Override + public int minHeight() { + return Math.max(5, super.minHeight()); + } + + @Override + public int minWidth() { + return Math.max(5, super.minWidth()); + } + @Override protected float fill() { //fill scales from ~30% at 4x4, to ~60% at 18x18 diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CaveEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CaveEntranceRoom.java new file mode 100644 index 000000000..49ab17654 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CaveEntranceRoom.java @@ -0,0 +1,69 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom; +import com.watabou.utils.PathFinder; + +public class CaveEntranceRoom extends CaveRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance; + do { + entrance = level.pointToCell(random(2)); + + } while (level.map[entrance] == Terrain.WALL || level.findMob(entrance) != null); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, entrance+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } + + @Override + public boolean connect(Room room) { + //cannot connect to exit, otherwise works normally + if (room.isExit()) return false; + else return super.connect(room); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/ChasmEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/ChasmEntranceRoom.java new file mode 100644 index 000000000..bfc5a2545 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/ChasmEntranceRoom.java @@ -0,0 +1,61 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ChasmRoom; +import com.watabou.utils.PathFinder; + +public class ChasmEntranceRoom extends ChasmRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance; + do { + entrance = level.pointToCell(random(2)); + + } while (level.map[entrance] == Terrain.CHASM || level.findMob(entrance) != null); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, entrance+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CircleBasinEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CircleBasinEntranceRoom.java new file mode 100644 index 000000000..d64e2058f --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/CircleBasinEntranceRoom.java @@ -0,0 +1,59 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CircleBasinRoom; + +public class CircleBasinEntranceRoom extends CircleBasinRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{0, 1, 0}; + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance = level.pointToCell(center()); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } + + @Override + public boolean connect(Room room) { + //cannot connect to exit, otherwise works normally + if (room.isExit()) return false; + else return super.connect(room); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java index dbd1b4f99..ee53630a8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/EntranceRoom.java @@ -34,6 +34,9 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.watabou.utils.Point; import com.watabou.utils.Random; +import com.watabou.utils.Reflection; + +import java.util.ArrayList; public class EntranceRoom extends StandardRoom { @@ -130,5 +133,45 @@ public class EntranceRoom extends StandardRoom { if (room.isExit()) return false; else return super.connect(room); } - + + private static ArrayList> rooms = new ArrayList<>(); + static { + rooms.add(EntranceRoom.class); + + + rooms.add(CircleBasinEntranceRoom.class); + + rooms.add(PillarsEntranceRoom.class); + + rooms.add(CaveEntranceRoom.class); + + rooms.add(HallwayEntranceRoom.class); + + rooms.add(ChasmEntranceRoom.class); + } + + private static float[][] chances = new float[27][]; + static { + chances[1] = new float[]{1, 0, 0, 0, 0, 0}; + chances[2] = chances[1]; + chances[3] = new float[]{5, 2, 0, 0, 0, 0}; + chances[5] = chances[4] = chances[3]; + + chances[6] = new float[]{5, 0, 5, 0, 0, 0}; + chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; + + chances[11] = new float[]{5, 0, 0, 5, 0, 0}; + chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; + + chances[16] = new float[]{5, 0, 0, 0, 5, 0}; + chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; + + chances[21] = new float[]{5, 0, 0, 0, 0, 5}; + chances[26] = chances[25] = chances[24] = chances[23] = chances[22] = chances[21]; + } + + public static StandardRoom createEntrance(){ + return Reflection.newInstance(rooms.get(Random.chances(chances[Dungeon.depth]))); + } + } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/HallwayEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/HallwayEntranceRoom.java new file mode 100644 index 000000000..53eaa4ee4 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/HallwayEntranceRoom.java @@ -0,0 +1,53 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.HallwayRoom; +import com.watabou.utils.Point; + +public class HallwayEntranceRoom extends HallwayRoom { + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance = -1; + for ( Point p : getPoints()){ + if (level.map[level.pointToCell(p)] == Terrain.STATUE_SP){ + entrance = level.pointToCell(p); + break; + } + } + Painter.set( level, entrance, Terrain.ENTRANCE ); + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/PillarsEntranceRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/PillarsEntranceRoom.java new file mode 100644 index 000000000..d05aec9b7 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/entrance/PillarsEntranceRoom.java @@ -0,0 +1,65 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.entrance; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.PillarsRoom; +import com.watabou.utils.PathFinder; + +public class PillarsEntranceRoom extends PillarsRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{3, 1, 0}; + } + + @Override + public boolean isEntrance() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int entrance; + boolean valid; + do { + entrance = level.pointToCell(random(2)); + valid = true; + + for (int i : PathFinder.NEIGHBOURS4){ + if (i == -level.width()) continue; + if (level.map[entrance+i] == Terrain.WALL){ + valid = false; + } + } + + } while (level.findMob(entrance) != null || level.map[entrance] == Terrain.WALL || !valid); + Painter.set( level, entrance, Terrain.ENTRANCE ); + + level.transitions.add(new LevelTransition(level, entrance, LevelTransition.Type.REGULAR_ENTRANCE)); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CaveExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CaveExitRoom.java new file mode 100644 index 000000000..9c18f5dc3 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CaveExitRoom.java @@ -0,0 +1,74 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CaveRoom; +import com.watabou.utils.PathFinder; +import com.watabou.utils.Point; + +public class CaveExitRoom extends CaveRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit; + do { + exit = level.pointToCell(random(2)); + + } while (level.map[exit] == Terrain.WALL || level.findMob(exit) != null); + Painter.set( level, exit, Terrain.EXIT ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, exit+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + + @Override + public boolean canPlaceCharacter(Point p, Level l) { + return super.canPlaceCharacter(p, l) && l.pointToCell(p) != l.exit(); + } + + @Override + public boolean connect(Room room) { + //cannot connect to entrance, otherwise works normally + if (room.isEntrance()) return false; + else return super.connect(room); + } +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ChasmExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ChasmExitRoom.java new file mode 100644 index 000000000..3e75189ea --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ChasmExitRoom.java @@ -0,0 +1,61 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ChasmRoom; +import com.watabou.utils.PathFinder; + +public class ChasmExitRoom extends ChasmRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{2, 1, 0}; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit; + do { + exit = level.pointToCell(random(2)); + + } while (level.map[exit] == Terrain.CHASM || level.findMob(exit) != null); + Painter.set( level, exit, Terrain.EXIT ); + + for (int i : PathFinder.NEIGHBOURS8){ + Painter.set( level, exit+i, Terrain.EMPTY ); + } + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleBasinExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleBasinExitRoom.java new file mode 100644 index 000000000..7cb5fecc4 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/CircleBasinExitRoom.java @@ -0,0 +1,60 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.CircleBasinRoom; + +public class CircleBasinExitRoom extends CircleBasinRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{0, 1, 0}; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit = level.pointToCell(center()); + Painter.set( level, exit, Terrain.EXIT ); + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + + @Override + public boolean connect(Room room) { + //cannot connect to exit, otherwise works normally + if (room.isExit()) return false; + else return super.connect(room); + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java index 285b38177..5e67e1a09 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/ExitRoom.java @@ -21,6 +21,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.exit; +import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; @@ -28,6 +29,10 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.watabou.utils.Point; +import com.watabou.utils.Random; +import com.watabou.utils.Reflection; + +import java.util.ArrayList; public class ExitRoom extends StandardRoom { @@ -71,4 +76,42 @@ public class ExitRoom extends StandardRoom { if (room.isEntrance()) return false; else return super.connect(room); } + + private static ArrayList> rooms = new ArrayList<>(); + static { + rooms.add(ExitRoom.class); + + + rooms.add(CircleBasinExitRoom.class); + + rooms.add(PillarsExitRoom.class); + + rooms.add(CaveExitRoom.class); + + rooms.add(HallwayExitRoom.class); + + rooms.add(ChasmExitRoom.class); + } + + private static float[][] chances = new float[27][]; + static { + chances[1] = new float[]{5, 2, 0, 0, 0, 0}; + chances[5] = chances[4] = chances[3] = chances[2] = chances[1]; + + chances[6] = new float[]{5, 0, 5, 0, 0, 0}; + chances[10] = chances[9] = chances[8] = chances[7] = chances[6]; + + chances[11] = new float[]{5, 0, 0, 5, 0, 0}; + chances[15] = chances[14] = chances[13] = chances[12] = chances[11]; + + chances[16] = new float[]{5, 0, 0, 0, 5, 0}; + chances[20] = chances[19] = chances[18] = chances[17] = chances[16]; + + chances[21] = new float[]{5, 0, 0, 0, 0, 5}; + chances[26] = chances[25] = chances[24] = chances[23] = chances[22] = chances[21]; + } + + public static StandardRoom createExit(){ + return Reflection.newInstance(rooms.get(Random.chances(chances[Dungeon.depth]))); + } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/HallwayExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/HallwayExitRoom.java new file mode 100644 index 000000000..068e82a36 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/HallwayExitRoom.java @@ -0,0 +1,54 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.HallwayRoom; +import com.watabou.utils.Point; + +public class HallwayExitRoom extends HallwayRoom { + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit = -1; + for ( Point p : getPoints()){ + if (level.map[level.pointToCell(p)] == Terrain.STATUE_SP){ + exit = level.pointToCell(p); + break; + } + } + Painter.set( level, exit, Terrain.EXIT ); + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + + } + +} diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/PillarsExitRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/PillarsExitRoom.java new file mode 100644 index 000000000..2f25993b5 --- /dev/null +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/exit/PillarsExitRoom.java @@ -0,0 +1,66 @@ +/* + * Pixel Dungeon + * Copyright (C) 2012-2015 Oleg Dolya + * + * Shattered Pixel Dungeon + * Copyright (C) 2014-2024 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.exit; + +import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; +import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.PillarsRoom; +import com.watabou.utils.PathFinder; + +public class PillarsExitRoom extends PillarsRoom { + + @Override + public float[] sizeCatProbs() { + return new float[]{3, 1, 0}; + } + + @Override + public boolean isExit() { + return true; + } + + @Override + public void paint(Level level) { + super.paint(level); + + int exit; + boolean valid; + do { + exit = level.pointToCell(random(2)); + valid = true; + + for (int i : PathFinder.NEIGHBOURS4){ + if (i == -level.width()) continue; + if (level.map[exit+i] == Terrain.WALL){ + valid = false; + } + } + + } while (level.findMob(exit) != null || level.map[exit] == Terrain.WALL || !valid); + Painter.set( level, exit, Terrain.EXIT ); + + level.transitions.add(new LevelTransition(level, exit, LevelTransition.Type.REGULAR_EXIT)); + } + +}