v0.6.0: refactoring room painters into room types pt.2
This commit is contained in:
parent
e9a7384779
commit
0a5e33a5af
6
core/proguard-rules.pro
vendored
6
core/proguard-rules.pro
vendored
|
@ -1,4 +1,4 @@
|
||||||
# retain these to support reflection and meaningful stack traces
|
# retain these to support class references and meaningful stack traces
|
||||||
-keep class com.shatteredpixel.** { *; }
|
-keepnames class com.shatteredpixel.** { *; }
|
||||||
-keep class com.watabou.** { *; }
|
-keepnames class com.watabou.** { *; }
|
||||||
-keepattributes SourceFile,LineNumberTable
|
-keepattributes SourceFile,LineNumberTable
|
|
@ -32,8 +32,9 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
|
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
|
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfUpgrade;
|
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.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite;
|
import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite;
|
||||||
|
@ -44,7 +45,7 @@ import com.watabou.noosa.audio.Sample;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Blacksmith extends NPC {
|
public class Blacksmith extends NPC {
|
||||||
|
|
||||||
|
@ -278,14 +279,14 @@ public class Blacksmith extends NPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean spawn( Collection<Room> rooms ) {
|
public static boolean spawn( ArrayList<Room> rooms ) {
|
||||||
if (!spawned && Dungeon.depth > 11 && Random.Int( 15 - Dungeon.depth ) == 0) {
|
if (!spawned && Dungeon.depth > 11 && Random.Int( 15 - Dungeon.depth ) == 0) {
|
||||||
|
|
||||||
Room blacksmith;
|
Room blacksmith;
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r.type == Type.STANDARD && r.width() > 4 && r.height() > 4) {
|
if (r instanceof StandardRoom && r.width() > 4 && r.height() > 4) {
|
||||||
blacksmith = r;
|
blacksmith = new BlacksmithRoom().set(r);
|
||||||
blacksmith.type = Type.BLACKSMITH;
|
rooms.set(rooms.indexOf(r), blacksmith);
|
||||||
|
|
||||||
spawned = true;
|
spawned = true;
|
||||||
alternative = Random.Int( 2 ) == 0;
|
alternative = Random.Int( 2 ) == 0;
|
||||||
|
@ -295,6 +296,7 @@ public class Blacksmith extends NPC {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return spawned;
|
return spawned;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
|
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel;
|
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.Room;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RotGardenRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
|
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
@ -43,6 +47,7 @@ import com.shatteredpixel.shatteredpixeldungeon.windows.WndWandmaker;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class Wandmaker extends NPC {
|
public class Wandmaker extends NPC {
|
||||||
|
@ -278,7 +283,7 @@ public class Wandmaker extends NPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean spawnRoom( Collection<Room> rooms) {
|
public static boolean spawnRoom( ArrayList<Room> rooms) {
|
||||||
questRoomSpawned = false;
|
questRoomSpawned = false;
|
||||||
if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int( 10 - Dungeon.depth ) == 0))) {
|
if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int( 10 - Dungeon.depth ) == 0))) {
|
||||||
|
|
||||||
|
@ -290,7 +295,7 @@ public class Wandmaker extends NPC {
|
||||||
//we don't re-roll the quest, it will try to assign itself to that new level with the same type.
|
//we don't re-roll the quest, it will try to assign itself to that new level with the same type.
|
||||||
Room questRoom = null;
|
Room questRoom = null;
|
||||||
for (Room r : rooms){
|
for (Room r : rooms){
|
||||||
if (r.type == Room.Type.STANDARD && r.width() > 5 && r.height() > 5){
|
if (r instanceof StandardRoom && r.width() > 5 && r.height() > 5){
|
||||||
if (type == 2 || r.connected.size() == 1){
|
if (type == 2 || r.connected.size() == 1){
|
||||||
questRoom = r;
|
questRoom = r;
|
||||||
break;
|
break;
|
||||||
|
@ -302,17 +307,19 @@ public class Wandmaker extends NPC {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Room temp = questRoom;
|
||||||
switch (type){
|
switch (type){
|
||||||
case 1: default:
|
case 1: default:
|
||||||
questRoom.type = Room.Type.MASS_GRAVE;
|
questRoom = new MassGraveRoom().set(temp);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
questRoom.type = Room.Type.RITUAL_SITE;
|
questRoom = new RitualSiteRoom().set(temp);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
questRoom.type = Room.Type.ROT_GARDEN;
|
questRoom = new RotGardenRoom().set(temp);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
rooms.set(rooms.indexOf(temp), questRoom);
|
||||||
|
|
||||||
questRoomSpawned = true;
|
questRoomSpawned = true;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -24,7 +24,8 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TunnelRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
|
||||||
|
@ -101,7 +102,7 @@ public class CavesLevel extends RegularLevel {
|
||||||
protected void decorate() {
|
protected void decorate() {
|
||||||
|
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room.type != Room.Type.STANDARD) {
|
if (!(room instanceof StandardRoom)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +145,7 @@ public class CavesLevel extends RegularLevel {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Room n : room.connected.keySet()) {
|
for (Room n : room.connected.keySet()) {
|
||||||
if ((n.type == Room.Type.STANDARD || n.type == Room.Type.TUNNEL) && Random.Int( 3 ) == 0) {
|
if ((n instanceof StandardRoom || n instanceof TunnelRoom) && Random.Int( 3 ) == 0) {
|
||||||
Painter.set( this, room.connected.get( n ), Terrain.EMPTY_DECO );
|
Painter.set( this, room.connected.get( n ), Terrain.EMPTY_DECO );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -186,9 +187,9 @@ public class CavesLevel extends RegularLevel {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r.type == Type.STANDARD) {
|
if (r instanceof StandardRoom) {
|
||||||
for (Room n : r.neigbours) {
|
for (Room n : r.neigbours) {
|
||||||
if (n.type == Type.STANDARD && !r.connected.containsKey( n )) {
|
if (n instanceof StandardRoom && !r.connected.containsKey( n )) {
|
||||||
Rect w = r.intersect( n );
|
Rect w = r.intersect( n );
|
||||||
if (w.left == w.right && w.bottom - w.top >= 5) {
|
if (w.left == w.right && w.bottom - w.top >= 5) {
|
||||||
|
|
||||||
|
|
|
@ -303,11 +303,11 @@ public class PrisonBossLevel extends Level {
|
||||||
HealthIndicator.instance.target(null);
|
HealthIndicator.instance.target(null);
|
||||||
tengu.sprite.kill();
|
tengu.sprite.kill();
|
||||||
|
|
||||||
Room maze = new Room();
|
Room maze = new MazeRoom();
|
||||||
maze.set(10, 1, 31, 29);
|
maze.set(10, 1, 31, 29);
|
||||||
maze.connected.put(null, new Room.Door(10, 2));
|
maze.connected.put(null, new Room.Door(10, 2));
|
||||||
maze.connected.put(maze, new Room.Door(20, 29));
|
maze.connected.put(maze, new Room.Door(20, 29));
|
||||||
MazeRoom.paint(this, maze);
|
maze.paint(this);
|
||||||
buildFlagMaps();
|
buildFlagMaps();
|
||||||
cleanWalls();
|
cleanWalls();
|
||||||
GameScene.resetMap();
|
GameScene.resetMap();
|
||||||
|
|
|
@ -34,8 +34,14 @@ import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.Scroll;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.EntranceRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ExitRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PassageRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PitRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TunnelRoom;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
|
||||||
|
@ -117,7 +123,7 @@ public abstract class RegularLevel extends Level {
|
||||||
if (feeling == Feeling.GRASS) {
|
if (feeling == Feeling.GRASS) {
|
||||||
|
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room.type != Type.NULL && room.type != Type.PASSAGE && room.type != Type.TUNNEL) {
|
if (!(room instanceof TunnelRoom || room instanceof PassageRoom)) {
|
||||||
grass[(room.left + 1) + (room.top + 1) * width()] = true;
|
grass[(room.left + 1) + (room.top + 1) * width()] = true;
|
||||||
grass[(room.right - 1) + (room.top + 1) * width()] = true;
|
grass[(room.right - 1) + (room.top + 1) * width()] = true;
|
||||||
grass[(room.left + 1) + (room.bottom - 1) * width()] = true;
|
grass[(room.left + 1) + (room.bottom - 1) * width()] = true;
|
||||||
|
@ -156,7 +162,7 @@ public abstract class RegularLevel extends Level {
|
||||||
if(Dungeon.depth == 1){
|
if(Dungeon.depth == 1){
|
||||||
//extra check to prevent annoying inactive traps in hallways on floor 1
|
//extra check to prevent annoying inactive traps in hallways on floor 1
|
||||||
Room r = room(i);
|
Room r = room(i);
|
||||||
if (r != null && r.type != Type.TUNNEL){
|
if (r instanceof StandardRoom){
|
||||||
validCells.add(i);
|
validCells.add(i);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -201,14 +207,8 @@ public abstract class RegularLevel extends Level {
|
||||||
protected boolean paint() {
|
protected boolean paint() {
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r.type != Type.NULL) {
|
|
||||||
placeDoors( r );
|
placeDoors( r );
|
||||||
r.type.paint( this, r );
|
r.paint( this );
|
||||||
} else {
|
|
||||||
if (feeling == Feeling.CHASM && Random.Int( 2 ) == 0) {
|
|
||||||
Painter.fill( this, r, Terrain.WALL );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
|
@ -287,7 +287,7 @@ public abstract class RegularLevel extends Level {
|
||||||
|
|
||||||
protected boolean joinRooms( Room r, Room n ) {
|
protected boolean joinRooms( Room r, Room n ) {
|
||||||
|
|
||||||
if (r.type != Room.Type.STANDARD || n.type != Room.Type.STANDARD) {
|
if (!(r instanceof StandardRoom && n instanceof StandardRoom)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,7 +356,7 @@ public abstract class RegularLevel extends Level {
|
||||||
|
|
||||||
ArrayList<Room> stdRooms = new ArrayList<>();
|
ArrayList<Room> stdRooms = new ArrayList<>();
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room.type == Type.STANDARD) stdRooms.add(room);
|
if (room instanceof StandardRoom) stdRooms.add(room);
|
||||||
}
|
}
|
||||||
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
Iterator<Room> stdRoomIter = stdRooms.iterator();
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ public abstract class RegularLevel extends Level {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Room room = randomRoom( Room.Type.STANDARD, 10 );
|
Room room = randomRoom( StandardRoom.class, 10 );
|
||||||
if (room == null) {
|
if (room == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -501,10 +501,10 @@ public abstract class RegularLevel extends Level {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Room randomRoom( Room.Type type, int tries ) {
|
protected Room randomRoom( Class<?extends Room> type, int tries ) {
|
||||||
for (int i=0; i < tries; i++) {
|
for (int i=0; i < tries; i++) {
|
||||||
Room room = Random.element( rooms );
|
Room room = Random.element( rooms );
|
||||||
if (room.type == type) {
|
if (room.getClass().equals(type)) {
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ public abstract class RegularLevel extends Level {
|
||||||
|
|
||||||
public Room room( int pos ) {
|
public Room room( int pos ) {
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room.type != Type.NULL && room.inside( cellToPoint(pos) )) {
|
if (room.inside( cellToPoint(pos) )) {
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,7 @@ public abstract class RegularLevel extends Level {
|
||||||
|
|
||||||
protected int randomDropCell() {
|
protected int randomDropCell() {
|
||||||
while (true) {
|
while (true) {
|
||||||
Room room = randomRoom( Room.Type.STANDARD, 1 );
|
Room room = randomRoom( StandardRoom.class, 1 );
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
int pos = pointToCell(room.random());
|
int pos = pointToCell(room.random());
|
||||||
if (passable[pos]) {
|
if (passable[pos]) {
|
||||||
|
@ -536,7 +536,7 @@ public abstract class RegularLevel extends Level {
|
||||||
@Override
|
@Override
|
||||||
public int pitCell() {
|
public int pitCell() {
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room.type == Type.PIT) {
|
if (room instanceof PitRoom) {
|
||||||
return pointToCell(room.random());
|
return pointToCell(room.random());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -555,15 +555,16 @@ public abstract class RegularLevel extends Level {
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
super.restoreFromBundle( bundle );
|
super.restoreFromBundle( bundle );
|
||||||
|
|
||||||
|
//TODO implement legacytype support here
|
||||||
rooms = new ArrayList<>( (Collection<Room>) ((Collection<?>) bundle.getCollection( "rooms" )) );
|
rooms = new ArrayList<>( (Collection<Room>) ((Collection<?>) bundle.getCollection( "rooms" )) );
|
||||||
for (Room r : rooms) {
|
for (Room r : rooms) {
|
||||||
if (r.type == Type.WEAK_FLOOR) {
|
if (r instanceof WeakFloorRoom || r.legacyType.equals("WEAK_FLOOR")) {
|
||||||
weakFloorCreated = true;
|
weakFloorCreated = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (r.type == Type.ENTRANCE){
|
if (r instanceof EntranceRoom || r.legacyType.equals("ENTRANCE")){
|
||||||
roomEntrance = r;
|
roomEntrance = r;
|
||||||
} else if (r.type == Type.EXIT){
|
} else if (r instanceof ExitRoom || r.legacyType.equals("EXIT")){
|
||||||
roomExit = r;
|
roomExit = r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.watabou.noosa.Group;
|
import com.watabou.noosa.Group;
|
||||||
|
@ -128,7 +128,7 @@ public class SewerBossLevel extends RegularLevel {
|
||||||
Room room;
|
Room room;
|
||||||
do {
|
do {
|
||||||
room = Random.element(rooms);
|
room = Random.element(rooms);
|
||||||
} while (room.type != Type.STANDARD);
|
} while (!(room instanceof StandardRoom));
|
||||||
mob.pos = pointToCell(room.random());
|
mob.pos = pointToCell(room.random());
|
||||||
mobs.add( mob );
|
mobs.add( mob );
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,18 +2,37 @@ package com.shatteredpixel.shatteredpixeldungeon.levels.builders;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
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.Room;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ShopRoom;
|
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.watabou.utils.Graph;
|
import com.watabou.utils.Graph;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.ListIterator;
|
||||||
|
|
||||||
//This builder exactly mimics pre-0.6.0 levelgen, including all of its limitations
|
//This builder exactly mimics pre-0.6.0 levelgen, including all of its limitations
|
||||||
//Currently implemented during this transition period, it will likely not survive to 0.6.0 release
|
//Currently implemented during this transition period, it will likely not survive to 0.6.0 release
|
||||||
|
@ -44,7 +63,7 @@ public class LegacyBuilder extends Builder {
|
||||||
public Room roomEntrance;
|
public Room roomEntrance;
|
||||||
public Room roomExit;
|
public Room roomExit;
|
||||||
|
|
||||||
protected ArrayList<Room.Type> specials;
|
protected ArrayList<Class<?extends Room>> specials;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//The list of rooms passed to this method is ignored
|
//The list of rooms passed to this method is ignored
|
||||||
|
@ -86,8 +105,13 @@ public class LegacyBuilder extends Builder {
|
||||||
|
|
||||||
} while (distance < minDistance);
|
} while (distance < minDistance);
|
||||||
|
|
||||||
roomEntrance.type = Room.Type.ENTRANCE;
|
Room temp = roomEntrance;
|
||||||
roomExit.type = Room.Type.EXIT;
|
roomEntrance = new EntranceRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomEntrance);
|
||||||
|
|
||||||
|
temp = roomExit;
|
||||||
|
roomExit = new ExitRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomExit);
|
||||||
|
|
||||||
ArrayList<Room> connected = new ArrayList<>();
|
ArrayList<Room> connected = new ArrayList<>();
|
||||||
connected.add( roomEntrance );
|
connected.add( roomEntrance );
|
||||||
|
@ -138,21 +162,23 @@ public class LegacyBuilder extends Builder {
|
||||||
if (shop == null) {
|
if (shop == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
shop.type = Room.Type.SHOP;
|
temp = shop;
|
||||||
|
shop = new LaboratoryRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), shop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
specials = new ArrayList<Room.Type>( Room.SPECIALS );
|
specials = new ArrayList<Class<? extends Room>>( Room.SPECIALS );
|
||||||
if (Dungeon.bossLevel( Dungeon.depth + 1 )) {
|
if (Dungeon.bossLevel( Dungeon.depth + 1 )) {
|
||||||
specials.remove( Room.Type.WEAK_FLOOR );
|
specials.remove( WeakFloorRoom.class );
|
||||||
}
|
}
|
||||||
if (Dungeon.isChallenged( Challenges.NO_ARMOR )){
|
if (Dungeon.isChallenged( Challenges.NO_ARMOR )){
|
||||||
//no sense in giving an armor reward room on a run with no armor.
|
//no sense in giving an armor reward room on a run with no armor.
|
||||||
specials.remove( Room.Type.CRYPT );
|
specials.remove( CryptRoom.class );
|
||||||
}
|
}
|
||||||
if (Dungeon.isChallenged( Challenges.NO_HERBALISM )){
|
if (Dungeon.isChallenged( Challenges.NO_HERBALISM )){
|
||||||
//sorry warden, no lucky sungrass or blandfruit seeds for you!
|
//sorry warden, no lucky sungrass or blandfruit seeds for you!
|
||||||
specials.remove( Room.Type.GARDEN );
|
specials.remove( GardenRoom.class );
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!assignRoomType())
|
if (!assignRoomType())
|
||||||
|
@ -167,8 +193,12 @@ public class LegacyBuilder extends Builder {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ArrayList<Room> resultRooms = new ArrayList<>();
|
||||||
|
for (Room r : rooms)
|
||||||
|
if (!r.getClass().equals(Room.class))
|
||||||
|
resultRooms.add(r);
|
||||||
|
|
||||||
return rooms;
|
return resultRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<Room> buildSewerBossLevel(){
|
private ArrayList<Room> buildSewerBossLevel(){
|
||||||
|
@ -185,10 +215,11 @@ public class LegacyBuilder extends Builder {
|
||||||
roomEntrance = Random.element( rooms );
|
roomEntrance = Random.element( rooms );
|
||||||
} while (roomEntrance.width() != 8 || roomEntrance.height() < 5 || roomEntrance.top == 0 || roomEntrance.top >= 8);
|
} while (roomEntrance.width() != 8 || roomEntrance.height() < 5 || roomEntrance.top == 0 || roomEntrance.top >= 8);
|
||||||
|
|
||||||
roomEntrance.type = Room.Type.ENTRANCE;
|
Room temp = roomEntrance;
|
||||||
|
roomEntrance = new EntranceRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomEntrance);
|
||||||
roomExit = roomEntrance;
|
roomExit = roomEntrance;
|
||||||
|
|
||||||
|
|
||||||
//now find the rest of the rooms for this boss mini-maze
|
//now find the rest of the rooms for this boss mini-maze
|
||||||
Room curRoom = null;
|
Room curRoom = null;
|
||||||
Room lastRoom = roomEntrance;
|
Room lastRoom = roomEntrance;
|
||||||
|
@ -205,9 +236,11 @@ public class LegacyBuilder extends Builder {
|
||||||
curRoom = Random.element(rooms);
|
curRoom = Random.element(rooms);
|
||||||
Graph.buildDistanceMap(rooms, curRoom);
|
Graph.buildDistanceMap(rooms, curRoom);
|
||||||
distance = lastRoom.distance();
|
distance = lastRoom.distance();
|
||||||
} while (curRoom.type != Room.Type.NULL || distance != 3 || curRoom.neigbours.contains(roomEntrance));
|
} while (!(curRoom.getClass().equals(Room.class)) || distance != 3 || curRoom.neigbours.contains(roomEntrance));
|
||||||
|
|
||||||
curRoom.type = Room.Type.STANDARD;
|
temp = curRoom;
|
||||||
|
curRoom = new StandardRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), curRoom);
|
||||||
|
|
||||||
//otherwise, we're on the last iteration.
|
//otherwise, we're on the last iteration.
|
||||||
} else {
|
} else {
|
||||||
|
@ -235,7 +268,7 @@ public class LegacyBuilder extends Builder {
|
||||||
//look at rooms adjacent to the final found room (likely to be furthest from start)
|
//look at rooms adjacent to the final found room (likely to be furthest from start)
|
||||||
ArrayList<Room> candidates = new ArrayList<Room>();
|
ArrayList<Room> candidates = new ArrayList<Room>();
|
||||||
for (Room r : lastRoom.neigbours) {
|
for (Room r : lastRoom.neigbours) {
|
||||||
if (r.type == Room.Type.NULL && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
|
if (r.getClass().equals(Room.class) && r.connected.size() == 0 && !r.neigbours.contains(roomEntrance)) {
|
||||||
candidates.add(r);
|
candidates.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +277,10 @@ public class LegacyBuilder extends Builder {
|
||||||
if (candidates.size() > 0) {
|
if (candidates.size() > 0) {
|
||||||
Room kingsRoom = Random.element(candidates);
|
Room kingsRoom = Random.element(candidates);
|
||||||
kingsRoom.connect(lastRoom);
|
kingsRoom.connect(lastRoom);
|
||||||
kingsRoom.type = Room.Type.RAT_KING;
|
|
||||||
|
temp = kingsRoom;
|
||||||
|
kingsRoom = new RatKingRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), kingsRoom);
|
||||||
|
|
||||||
//unacceptable! make a new level...
|
//unacceptable! make a new level...
|
||||||
} else {
|
} else {
|
||||||
|
@ -259,13 +295,20 @@ public class LegacyBuilder extends Builder {
|
||||||
//and boring.
|
//and boring.
|
||||||
|
|
||||||
//fills our connection rooms in with tunnel
|
//fills our connection rooms in with tunnel
|
||||||
for (Room r : rooms) {
|
ListIterator<Room> it = rooms.listIterator();
|
||||||
if (r.type == Room.Type.NULL && r.connected.size() > 0) {
|
while (it.hasNext()) {
|
||||||
r.type = Room.Type.TUNNEL;
|
Room r = it.next();
|
||||||
|
if (r.getClass().equals(Room.class) && r.connected.size() > 0) {
|
||||||
|
it.set(new TunnelRoom().set(r));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rooms;
|
ArrayList<Room> resultRooms = new ArrayList<>();
|
||||||
|
for (Room r : rooms)
|
||||||
|
if (!r.getClass().equals(Room.class))
|
||||||
|
resultRooms.add(r);
|
||||||
|
|
||||||
|
return resultRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<Room> buildsLastShopLevel(){
|
private ArrayList<Room> buildsLastShopLevel(){
|
||||||
|
@ -298,8 +341,13 @@ public class LegacyBuilder extends Builder {
|
||||||
|
|
||||||
} while (distance < minDistance);
|
} while (distance < minDistance);
|
||||||
|
|
||||||
roomEntrance.type = Room.Type.ENTRANCE;
|
Room temp = roomEntrance;
|
||||||
roomExit.type = Room.Type.EXIT;
|
roomEntrance = new EntranceRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomEntrance);
|
||||||
|
|
||||||
|
temp = roomExit;
|
||||||
|
roomExit = new ExitRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomExit);
|
||||||
|
|
||||||
Graph.buildDistanceMap( rooms, roomExit );
|
Graph.buildDistanceMap( rooms, roomExit );
|
||||||
List<Room> path = Graph.buildPath( rooms, roomEntrance, roomExit );
|
List<Room> path = Graph.buildPath( rooms, roomEntrance, roomExit );
|
||||||
|
@ -317,9 +365,11 @@ public class LegacyBuilder extends Builder {
|
||||||
|
|
||||||
Room roomShop = null;
|
Room roomShop = null;
|
||||||
int shopSquare = 0;
|
int shopSquare = 0;
|
||||||
for (Room r : rooms) {
|
ListIterator<Room> it = rooms.listIterator();
|
||||||
if (r.type == Room.Type.NULL && r.connected.size() > 0) {
|
while (it.hasNext()) {
|
||||||
r.type = Room.Type.PASSAGE;
|
Room r = it.next();
|
||||||
|
if (r.getClass().equals(Room.class) && r.connected.size() > 0) {
|
||||||
|
it.set(r = new PassageRoom().set(r));
|
||||||
if (r.square() > shopSquare) {
|
if (r.square() > shopSquare) {
|
||||||
roomShop = r;
|
roomShop = r;
|
||||||
shopSquare = r.square();
|
shopSquare = r.square();
|
||||||
|
@ -330,10 +380,17 @@ public class LegacyBuilder extends Builder {
|
||||||
if (roomShop == null || shopSquare < 54) {
|
if (roomShop == null || shopSquare < 54) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
roomShop.type = Imp.Quest.isCompleted() ? Room.Type.SHOP : Room.Type.STANDARD;
|
temp = roomShop;
|
||||||
|
roomShop = Imp.Quest.isCompleted() ? new ShopRoom().set(temp) : new StandardRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), roomShop);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rooms;
|
ArrayList<Room> resultRooms = new ArrayList<>();
|
||||||
|
for (Room r : rooms)
|
||||||
|
if (!r.getClass().equals(Room.class))
|
||||||
|
resultRooms.add(r);
|
||||||
|
|
||||||
|
return resultRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean initRooms(){
|
private boolean initRooms(){
|
||||||
|
@ -397,8 +454,11 @@ public class LegacyBuilder extends Builder {
|
||||||
int specialRooms = 0;
|
int specialRooms = 0;
|
||||||
boolean pitMade = false;
|
boolean pitMade = false;
|
||||||
|
|
||||||
for (Room r : rooms) {
|
ListIterator<Room> it = rooms.listIterator();
|
||||||
if (r.type == Room.Type.NULL &&
|
while (it.hasNext()) {
|
||||||
|
Room r = it.next();
|
||||||
|
Room temp;
|
||||||
|
if (r.getClass().equals(Room.class) &&
|
||||||
r.connected.size() == 1) {
|
r.connected.size() == 1) {
|
||||||
|
|
||||||
if (specials.size() > 0 &&
|
if (specials.size() > 0 &&
|
||||||
|
@ -407,38 +467,50 @@ public class LegacyBuilder extends Builder {
|
||||||
|
|
||||||
if (Level.pitRoomNeeded && !pitMade) {
|
if (Level.pitRoomNeeded && !pitMade) {
|
||||||
|
|
||||||
r.type = Room.Type.PIT;
|
temp = r;
|
||||||
|
r = new PitRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), r);
|
||||||
pitMade = true;
|
pitMade = true;
|
||||||
|
|
||||||
specials.remove( Room.Type.ARMORY );
|
specials.remove( ArmoryRoom.class );
|
||||||
specials.remove( Room.Type.CRYPT );
|
specials.remove( CryptRoom.class );
|
||||||
specials.remove( Room.Type.LABORATORY );
|
specials.remove( LaboratoryRoom.class );
|
||||||
specials.remove( Room.Type.LIBRARY );
|
specials.remove( LibraryRoom.class );
|
||||||
specials.remove( Room.Type.STATUE );
|
specials.remove( StatueRoom.class );
|
||||||
specials.remove( Room.Type.TREASURY );
|
specials.remove( TreasuryRoom.class );
|
||||||
specials.remove( Room.Type.VAULT );
|
specials.remove( VaultRoom.class );
|
||||||
specials.remove( Room.Type.WEAK_FLOOR );
|
specials.remove( WeakFloorRoom.class );
|
||||||
|
|
||||||
} else if (Dungeon.depth % 5 == 2 && specials.contains( Room.Type.LABORATORY )) {
|
} else if (Dungeon.depth % 5 == 2 && specials.contains( LaboratoryRoom.class )) {
|
||||||
|
|
||||||
r.type = Room.Type.LABORATORY;
|
temp = r;
|
||||||
|
r = new LaboratoryRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), r);
|
||||||
|
|
||||||
} else if (Dungeon.depth >= Dungeon.transmutation && specials.contains( Room.Type.MAGIC_WELL )) {
|
} else if (Dungeon.depth >= Dungeon.transmutation && specials.contains( MagicWellRoom.class )) {
|
||||||
|
|
||||||
r.type = Room.Type.MAGIC_WELL;
|
temp = r;
|
||||||
|
r = new MagicWellRoom().set(temp);
|
||||||
|
rooms.set(rooms.indexOf(temp), r);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
int n = specials.size();
|
int n = specials.size();
|
||||||
r.type = specials.get( Math.min( Random.Int( n ), Random.Int( n ) ) );
|
temp = r;
|
||||||
if (r.type == Room.Type.WEAK_FLOOR) {
|
try {
|
||||||
|
r = specials.get( Math.min( Random.Int( n ), Random.Int( n ) ) ).newInstance().set(temp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
ShatteredPixelDungeon.reportException(e);
|
||||||
|
}
|
||||||
|
rooms.set(rooms.indexOf(temp), r);
|
||||||
|
if (r instanceof WeakFloorRoom) {
|
||||||
Level.weakFloorCreated = true;
|
Level.weakFloorCreated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Room.useType( r.type );
|
Room.useType( r.getClass() );
|
||||||
specials.remove( r.type );
|
specials.remove( r.getClass() );
|
||||||
specialRooms++;
|
specialRooms++;
|
||||||
|
|
||||||
} else if (Random.Int( 2 ) == 0){
|
} else if (Random.Int( 2 ) == 0){
|
||||||
|
@ -446,8 +518,8 @@ public class LegacyBuilder extends Builder {
|
||||||
ArrayList<Room> neigbours = new ArrayList<>();
|
ArrayList<Room> neigbours = new ArrayList<>();
|
||||||
for (Room n : r.neigbours) {
|
for (Room n : r.neigbours) {
|
||||||
if (!r.connected.containsKey( n ) &&
|
if (!r.connected.containsKey( n ) &&
|
||||||
!Room.SPECIALS.contains( n.type ) &&
|
!Room.SPECIALS.contains( n.getClass() ) &&
|
||||||
n.type != Room.Type.PIT) {
|
!(n instanceof PitRoom)) {
|
||||||
|
|
||||||
neigbours.add( n );
|
neigbours.add( n );
|
||||||
}
|
}
|
||||||
|
@ -461,23 +533,29 @@ public class LegacyBuilder extends Builder {
|
||||||
|
|
||||||
if (Level.pitRoomNeeded && !pitMade) return false;
|
if (Level.pitRoomNeeded && !pitMade) return false;
|
||||||
|
|
||||||
Room.Type tunnelType = Room.Type.TUNNEL;
|
Class<? extends Room> tunnelType = TunnelRoom.class;
|
||||||
if ((Dungeon.depth > 5 && Dungeon.depth <= 10) ||
|
if ((Dungeon.depth > 5 && Dungeon.depth <= 10) ||
|
||||||
(Dungeon.depth > 15 && Dungeon.depth <= 20)){
|
(Dungeon.depth > 15 && Dungeon.depth <= 20)){
|
||||||
tunnelType = Room.Type.PASSAGE;
|
tunnelType = PassageRoom.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Room r : rooms) {
|
it = rooms.listIterator();
|
||||||
if (r.type == Room.Type.NULL) {
|
while (it.hasNext()) {
|
||||||
|
Room r = it.next();
|
||||||
|
if (r.getClass().equals(Room.class)) {
|
||||||
int connections = r.connected.size();
|
int connections = r.connected.size();
|
||||||
if (connections == 0) {
|
if (connections == 0) {
|
||||||
|
|
||||||
} else if (Random.Int( connections * connections ) == 0) {
|
} else if (Random.Int( connections * connections ) == 0) {
|
||||||
r.type = Room.Type.STANDARD;
|
it.set(new StandardRoom().set(r));
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
r.type = tunnelType;
|
if (tunnelType == TunnelRoom.class){
|
||||||
|
it.set(new TunnelRoom().set(r));
|
||||||
|
} else {
|
||||||
|
it.set(new PassageRoom().set(r));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -485,7 +563,7 @@ public class LegacyBuilder extends Builder {
|
||||||
while (count < 6) {
|
while (count < 6) {
|
||||||
Room r = randomRoom( tunnelType, 20 );
|
Room r = randomRoom( tunnelType, 20 );
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
r.type = Room.Type.STANDARD;
|
rooms.set(rooms.indexOf(r), new StandardRoom().set(r));
|
||||||
count++;
|
count++;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -495,10 +573,10 @@ public class LegacyBuilder extends Builder {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Room randomRoom( Room.Type type, int tries ) {
|
private Room randomRoom( Class<?extends Room> type, int tries ) {
|
||||||
for (int i=0; i < tries; i++) {
|
for (int i=0; i < tries; i++) {
|
||||||
Room room = Random.element( rooms );
|
Room room = Random.element( rooms );
|
||||||
if (room.type == type) {
|
if (room.getClass().equals(type)) {
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
||||||
|
@ -82,7 +83,7 @@ public class Chasm {
|
||||||
InterlevelScene.mode = InterlevelScene.Mode.FALL;
|
InterlevelScene.mode = InterlevelScene.Mode.FALL;
|
||||||
if (Dungeon.level instanceof RegularLevel) {
|
if (Dungeon.level instanceof RegularLevel) {
|
||||||
Room room = ((RegularLevel)Dungeon.level).room( pos );
|
Room room = ((RegularLevel)Dungeon.level).room( pos );
|
||||||
InterlevelScene.fallIntoPit = room != null && room.type == Room.Type.WEAK_FLOOR;
|
InterlevelScene.fallIntoPit = room != null && room instanceof WeakFloorRoom;
|
||||||
} else {
|
} else {
|
||||||
InterlevelScene.fallIntoPit = false;
|
InterlevelScene.fallIntoPit = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.watabou.utils.Point;
|
||||||
|
|
||||||
public class AltarRoom extends Room {
|
public class AltarRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM );
|
Painter.fill( level, room, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM );
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class ArmoryRoom extends Room {
|
public class ArmoryRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class BlacksmithRoom extends Room {
|
public class BlacksmithRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.TRAP );
|
Painter.fill( level, room, 1, Terrain.TRAP );
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.watabou.utils.Point;
|
||||||
|
|
||||||
public class CryptRoom extends Room {
|
public class CryptRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -27,7 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
|
|
||||||
public class EntranceRoom extends Room {
|
public class EntranceRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -27,7 +27,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
|
|
||||||
public class ExitRoom extends Room {
|
public class ExitRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -33,7 +33,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class GardenRoom extends Room {
|
public class GardenRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.HIGH_GRASS );
|
Painter.fill( level, room, 1, Terrain.HIGH_GRASS );
|
||||||
|
|
|
@ -35,7 +35,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class LaboratoryRoom extends Room {
|
public class LaboratoryRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
||||||
|
|
|
@ -36,7 +36,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class LibraryRoom extends Room {
|
public class LibraryRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class MagicWellRoom extends Room {
|
||||||
private static final Class<?>[] WATERS =
|
private static final Class<?>[] WATERS =
|
||||||
{WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class};
|
{WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class};
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -41,7 +41,7 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
public class MassGraveRoom extends Room {
|
public class MassGraveRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room){
|
public void paint( Level level, Room room){
|
||||||
|
|
||||||
Room.Door entrance = room.entrance();
|
Room.Door entrance = room.entrance();
|
||||||
entrance.set(Room.Door.Type.BARRICADE);
|
entrance.set(Room.Door.Type.BARRICADE);
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class MazeRoom extends Room {
|
public class MazeRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
Painter.fill(level, room, 1, Terrain.EMPTY);
|
Painter.fill(level, room, 1, Terrain.EMPTY);
|
||||||
|
|
||||||
//true = space, false = wall
|
//true = space, false = wall
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class PassageRoom extends Room {
|
||||||
private static int pasWidth;
|
private static int pasWidth;
|
||||||
private static int pasHeight;
|
private static int pasHeight;
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
pasWidth = room.width() - 2;
|
pasWidth = room.width() - 2;
|
||||||
pasHeight = room.height() - 2;
|
pasHeight = room.height() - 2;
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class PitRoom extends Room {
|
public class PitRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class PoolRoom extends Room {
|
||||||
|
|
||||||
private static final int NPIRANHAS = 3;
|
private static final int NPIRANHAS = 3;
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.WATER );
|
Painter.fill( level, room, 1, Terrain.WATER );
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class RatKingRoom extends Room {
|
public class RatKingRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Point;
|
||||||
|
|
||||||
public class RitualSiteRoom extends Room {
|
public class RitualSiteRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room) {
|
public void paint( Level level, Room room) {
|
||||||
|
|
||||||
for (Room.Door door : room.connected.values()) {
|
for (Room.Door door : room.connected.values()) {
|
||||||
door.set( Room.Door.Type.REGULAR );
|
door.set( Room.Door.Type.REGULAR );
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
|
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||||
import com.watabou.utils.Bundlable;
|
import com.watabou.utils.Bundlable;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
|
@ -30,7 +29,6 @@ import com.watabou.utils.Point;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
import com.watabou.utils.Rect;
|
import com.watabou.utils.Rect;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -52,75 +50,38 @@ public class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
super(other);
|
super(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Room( int left, int top, int right, int bottom ) {
|
public Room set( Room other ) {
|
||||||
super( left, top, right, bottom );
|
super.set( other );
|
||||||
|
for (Room r : other.neigbours){
|
||||||
|
neigbours.add(r);
|
||||||
|
r.neigbours.remove(other);
|
||||||
|
r.neigbours.add(this);
|
||||||
|
}
|
||||||
|
for (Room r : other.connected.keySet()){
|
||||||
|
Door d = other.connected.get(r);
|
||||||
|
r.connected.remove(other);
|
||||||
|
r.connected.put(this, d);
|
||||||
|
connected.put(r, d);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO convert these types into full subclasses of room
|
public void paint(Level level){
|
||||||
public static enum Type {
|
paint(level, this);
|
||||||
NULL( null ),
|
|
||||||
STANDARD ( StandardRoom.class ),
|
|
||||||
ENTRANCE ( EntranceRoom.class ),
|
|
||||||
EXIT ( ExitRoom.class ),
|
|
||||||
TUNNEL ( TunnelRoom.class ),
|
|
||||||
PASSAGE ( PassageRoom.class ),
|
|
||||||
SHOP ( ShopRoom.class ),
|
|
||||||
BLACKSMITH ( BlacksmithRoom.class ),
|
|
||||||
TREASURY ( TreasuryRoom.class ),
|
|
||||||
ARMORY ( ArmoryRoom.class ),
|
|
||||||
LIBRARY ( LibraryRoom.class ),
|
|
||||||
LABORATORY ( LaboratoryRoom.class ),
|
|
||||||
VAULT ( VaultRoom.class ),
|
|
||||||
TRAPS ( TrapsRoom.class ),
|
|
||||||
STORAGE ( StorageRoom.class ),
|
|
||||||
MAGIC_WELL ( MagicWellRoom.class ),
|
|
||||||
GARDEN ( GardenRoom.class ),
|
|
||||||
CRYPT ( CryptRoom.class ),
|
|
||||||
STATUE ( StatueRoom.class ),
|
|
||||||
POOL ( PoolRoom.class ),
|
|
||||||
RAT_KING ( RatKingRoom.class ),
|
|
||||||
WEAK_FLOOR ( WeakFloorRoom.class ),
|
|
||||||
PIT ( PitRoom.class ),
|
|
||||||
|
|
||||||
//prison quests
|
|
||||||
MASS_GRAVE ( MassGraveRoom.class ),
|
|
||||||
ROT_GARDEN ( RotGardenRoom.class ),
|
|
||||||
RITUAL_SITE ( RitualSiteRoom.class );
|
|
||||||
|
|
||||||
private Method paint;
|
|
||||||
|
|
||||||
Type( Class<? extends Room> painter ) {
|
|
||||||
if (painter == null)
|
|
||||||
paint = null;
|
|
||||||
else
|
|
||||||
try {
|
|
||||||
paint = painter.getMethod( "paint", Level.class, Room.class );
|
|
||||||
} catch (Exception e) {
|
|
||||||
ShatteredPixelDungeon.reportException(e);
|
|
||||||
paint = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paint(Level level, Room room){
|
public void paint(Level level, Room room){
|
||||||
try {
|
|
||||||
paint.invoke( null, level, room );
|
|
||||||
} catch (Exception e) {
|
|
||||||
ShatteredPixelDungeon.reportException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private static final ArrayList<Type> ALL_SPEC = new ArrayList<Type>( Arrays.asList(
|
}
|
||||||
Type.WEAK_FLOOR, Type.MAGIC_WELL, Type.CRYPT, Type.POOL, Type.GARDEN, Type.LIBRARY, Type.ARMORY,
|
|
||||||
Type.TREASURY, Type.TRAPS, Type.STORAGE, Type.STATUE, Type.LABORATORY, Type.VAULT
|
private static final ArrayList<Class<? extends Room>> 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
|
||||||
) );
|
) );
|
||||||
|
|
||||||
public static ArrayList<Type> SPECIALS = new ArrayList<Type>( Arrays.asList(
|
public static ArrayList<Class<? extends Room>> SPECIALS = new ArrayList<>();
|
||||||
Type.WEAK_FLOOR, Type.MAGIC_WELL, Type.CRYPT, Type.POOL, Type.GARDEN, Type.LIBRARY, Type.ARMORY,
|
|
||||||
Type.TREASURY, Type.TRAPS, Type.STORAGE, Type.STATUE, Type.LABORATORY, Type.VAULT
|
|
||||||
) );
|
|
||||||
|
|
||||||
public Type type = Type.NULL;
|
public String legacyType = "NULL";
|
||||||
|
|
||||||
public Point random() {
|
public Point random() {
|
||||||
return random( 0 );
|
return random( 0 );
|
||||||
|
@ -196,7 +157,8 @@ public class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
bundle.put( "top", top );
|
bundle.put( "top", top );
|
||||||
bundle.put( "right", right );
|
bundle.put( "right", right );
|
||||||
bundle.put( "bottom", bottom );
|
bundle.put( "bottom", bottom );
|
||||||
bundle.put( "type", type.toString() );
|
if (!legacyType.equals("NULL"))
|
||||||
|
bundle.put( "type", legacyType );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -205,35 +167,36 @@ public class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
top = bundle.getInt( "top" );
|
top = bundle.getInt( "top" );
|
||||||
right = bundle.getInt( "right" );
|
right = bundle.getInt( "right" );
|
||||||
bottom = bundle.getInt( "bottom" );
|
bottom = bundle.getInt( "bottom" );
|
||||||
type = Type.valueOf( bundle.getString( "type" ) );
|
if (bundle.contains( "type" ))
|
||||||
|
legacyType = bundle.getString( "type" );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void shuffleTypes() {
|
public static void shuffleTypes() {
|
||||||
SPECIALS = (ArrayList<Type>)ALL_SPEC.clone();
|
SPECIALS = (ArrayList<Class<?extends Room>>)ALL_SPEC.clone();
|
||||||
int size = SPECIALS.size();
|
int size = SPECIALS.size();
|
||||||
for (int i=0; i < size - 1; i++) {
|
for (int i=0; i < size - 1; i++) {
|
||||||
int j = Random.Int( i, size );
|
int j = Random.Int( i, size );
|
||||||
if (j != i) {
|
if (j != i) {
|
||||||
Type t = SPECIALS.get( i );
|
Class<?extends Room> c = SPECIALS.get( i );
|
||||||
SPECIALS.set( i, SPECIALS.get( j ) );
|
SPECIALS.set( i, SPECIALS.get( j ) );
|
||||||
SPECIALS.set( j, t );
|
SPECIALS.set( j, c );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void useType( Type type ) {
|
public static void useType( Class<?extends Room> type ) {
|
||||||
if (SPECIALS.remove( type )) {
|
if (SPECIALS.remove( type )) {
|
||||||
SPECIALS.add( type );
|
SPECIALS.add( type );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String ROOMS = "rooms";
|
private static final String ROOMS = "special_rooms";
|
||||||
|
|
||||||
public static void restoreRoomsFromBundle( Bundle bundle ) {
|
public static void restoreRoomsFromBundle( Bundle bundle ) {
|
||||||
if (bundle.contains( ROOMS )) {
|
if (bundle.contains( ROOMS )) {
|
||||||
SPECIALS.clear();
|
SPECIALS.clear();
|
||||||
for (String type : bundle.getStringArray( ROOMS )) {
|
for (Class<?extends Room> type : bundle.getClassArray( ROOMS )) {
|
||||||
SPECIALS.add( Type.valueOf( type ));
|
SPECIALS.add( type );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
shuffleTypes();
|
shuffleTypes();
|
||||||
|
@ -241,11 +204,7 @@ public class Room extends Rect implements Graph.Node, Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void storeRoomsInBundle( Bundle bundle ) {
|
public static void storeRoomsInBundle( Bundle bundle ) {
|
||||||
String[] array = new String[SPECIALS.size()];
|
bundle.put( ROOMS, SPECIALS.toArray(new Class[0]) );
|
||||||
for (int i=0; i < array.length; i++) {
|
|
||||||
array[i] = SPECIALS.get( i ).toString();
|
|
||||||
}
|
|
||||||
bundle.put( ROOMS, array );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Door extends Point {
|
public static class Door extends Point {
|
||||||
|
|
|
@ -34,7 +34,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class RotGardenRoom extends Room {
|
public class RotGardenRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Room.Door entrance = room.entrance();
|
Room.Door entrance = room.entrance();
|
||||||
entrance.set(Room.Door.Type.LOCKED);
|
entrance.set(Room.Door.Type.LOCKED);
|
||||||
|
|
|
@ -85,7 +85,7 @@ public class ShopRoom extends Room {
|
||||||
|
|
||||||
private static ArrayList<Item> itemsToSpawn;
|
private static ArrayList<Item> itemsToSpawn;
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
||||||
|
|
|
@ -35,7 +35,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class StandardRoom extends Room {
|
public class StandardRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
for (Room.Door door : room.connected.values()) {
|
for (Room.Door door : room.connected.values()) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ import com.watabou.utils.Point;
|
||||||
|
|
||||||
public class StatueRoom extends Room {
|
public class StatueRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class StorageRoom extends Room {
|
public class StorageRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
final int floor = Terrain.EMPTY_SP;
|
final int floor = Terrain.EMPTY_SP;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class TrapsRoom extends Room {
|
public class TrapsRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class TreasuryRoom extends Room {
|
public class TreasuryRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY );
|
Painter.fill( level, room, 1, Terrain.EMPTY );
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class TunnelRoom extends Room {
|
public class TunnelRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
int floor = level.tunnelTile();
|
int floor = level.tunnelTile();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class VaultRoom extends Room {
|
public class VaultRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
|
||||||
|
|
|
@ -33,7 +33,7 @@ import com.watabou.utils.Random;
|
||||||
|
|
||||||
public class WeakFloorRoom extends Room {
|
public class WeakFloorRoom extends Room {
|
||||||
|
|
||||||
public static void paint( Level level, Room room ) {
|
public void paint( Level level, Room room ) {
|
||||||
|
|
||||||
Painter.fill( level, room, Terrain.WALL );
|
Painter.fill( level, room, Terrain.WALL );
|
||||||
Painter.fill( level, room, 1, Terrain.CHASM );
|
Painter.fill( level, room, 1, Terrain.CHASM );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user