v2.4.0: added an entrance/exit variant for each region

This commit is contained in:
Evan Debenham
2024-04-18 10:07:14 -04:00
parent 792f681c88
commit 7e256333f4
15 changed files with 723 additions and 4 deletions

View File

@@ -114,8 +114,8 @@ public abstract class RegularLevel extends Level {
protected ArrayList<Room> initRooms() {
ArrayList<Room> 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);

View File

@@ -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){

View File

@@ -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

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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);
}
}

View File

@@ -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<Class<?extends StandardRoom>> 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])));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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);
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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);
}
}

View File

@@ -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<Class<?extends StandardRoom>> 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])));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}

View File

@@ -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 <http://www.gnu.org/licenses/>
*/
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));
}
}