v0.6.0: restructured room classes

This commit is contained in:
Evan Debenham 2017-03-29 17:52:20 -04:00
parent b01331e642
commit 0d366be632
39 changed files with 500 additions and 433 deletions

View File

@ -56,13 +56,13 @@ public class ShatteredPixelDungeon extends Game {
//v0.6.0
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom.Bones.class,
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom.Bones.class,
"com.shatteredpixel.shatteredpixeldungeon.levels.painters.MassGravePainter$Bones" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.RitualSiteRoom.RitualMarker.class,
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RitualSiteRoom.RitualMarker.class,
"com.shatteredpixel.shatteredpixeldungeon.levels.painters.RitualSitePainter$RitualMarker" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom.HiddenWell.class,
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom.HiddenWell.class,
"com.shatteredpixel.shatteredpixeldungeon.levels.painters.WeakFloorPainter$HiddenWell" );
com.watabou.utils.Bundle.addAlias(
com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room.class,

View File

@ -32,9 +32,9 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
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.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.BlacksmithRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite;
@ -279,6 +279,7 @@ public class Blacksmith extends NPC {
}
}
//FIXME: refactor this to work with new levelgen
public static boolean spawn( ArrayList<Room> rooms ) {
if (!spawned && Dungeon.depth > 11 && Random.Int( 15 - Dungeon.depth ) == 0) {

View File

@ -33,11 +33,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers;
import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand;
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.RotGardenRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RotGardenRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RitualSiteRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
@ -283,6 +283,7 @@ public class Wandmaker extends NPC {
}
}
//FIXME: refactor this to work with new levelgen
public static boolean spawnRoom( ArrayList<Room> rooms) {
questRoomSpawned = false;
if (!spawned && (type != 0 || (Dungeon.depth > 6 && Random.Int( 10 - Dungeon.depth ) == 0))) {

View File

@ -25,8 +25,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.TunnelRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.TunnelRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ConfusionTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;

View File

@ -68,7 +68,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Door;
import com.shatteredpixel.shatteredpixeldungeon.levels.features.HighGrass;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.MassGraveRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MassGraveRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;

View File

@ -36,12 +36,12 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.RegularPainter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.EntranceRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.ExitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.PitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ChillingTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ExplosiveTrap;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
@ -157,7 +157,7 @@ public abstract class RegularLevel extends Level {
ArrayList<Room> stdRooms = new ArrayList<>();
for (Room room : rooms) {
if (room instanceof StandardRoom) stdRooms.add(room);
if (room instanceof StandardRoom && room != roomEntrance) stdRooms.add(room);
}
Iterator<Room> stdRoomIter = stdRooms.iterator();
@ -346,7 +346,7 @@ public abstract class RegularLevel extends Level {
@Override
public int pitCell() {
for (Room room : rooms) {
if (room instanceof PitRoom) {
if (room instanceof PitRoom || room.legacyType.equals("PIT")) {
return pointToCell(room.random());
}
}

View File

@ -32,7 +32,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder;
import com.shatteredpixel.shatteredpixeldungeon.levels.builders.LegacyBuilder;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.noosa.Group;
@ -140,7 +140,7 @@ public class SewerBossLevel extends RegularLevel {
Room room;
do {
room = Random.element(rooms);
} while (!(room instanceof StandardRoom));
} while (!(room instanceof StandardRoom) || room == roomEntrance);
mob.pos = pointToCell(room.random());
mobs.add( mob );
}

View File

@ -7,25 +7,25 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker;
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.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.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ArmoryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.CryptRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.GardenRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LaboratoryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LibraryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicWellRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.RatKingRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StatueRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TreasuryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.VaultRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.EntranceRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.ExitRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.PassageRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel.TunnelRoom;
import com.watabou.utils.Graph;
import com.watabou.utils.Random;
import com.watabou.utils.Rect;
@ -419,14 +419,14 @@ public class LegacyBuilder extends Builder {
if (w > maxRoomSize && h < minRoomSize) {
int vw = Random.Int( rect.left + 3, rect.right - 3 );
int vw = Random.Int( rect.left + (minRoomSize/2), rect.right - (minRoomSize/2) );
split( new Rect( rect.left, rect.top, vw, rect.bottom ) );
split( new Rect( vw, rect.top, rect.right, rect.bottom ) );
} else
if (h > maxRoomSize && w < minRoomSize) {
int vh = Random.Int( rect.top + 3, rect.bottom - 3 );
int vh = Random.Int( rect.top + (minRoomSize/2), rect.bottom - (minRoomSize/2) );
split( new Rect( rect.left, rect.top, rect.right, vh ) );
split( new Rect( rect.left, vh, rect.right, rect.bottom ) );
@ -438,11 +438,11 @@ public class LegacyBuilder extends Builder {
} else {
if (Random.Float() < (float)(w - 2) / (w + h - 4)) {
int vw = Random.Int( rect.left + 3, rect.right - 3 );
int vw = Random.Int( rect.left + (minRoomSize/2), rect.right - (minRoomSize/2) );
split( new Rect( rect.left, rect.top, vw, rect.bottom ) );
split( new Rect( vw, rect.top, rect.right, rect.bottom ) );
} else {
int vh = Random.Int( rect.top + 3, rect.bottom - 3 );
int vh = Random.Int( rect.top + (minRoomSize/2), rect.bottom - (minRoomSize/2) );
split( new Rect( rect.left, rect.top, rect.right, vh ) );
split( new Rect( rect.left, vh, rect.right, rect.bottom ) );
}

View File

@ -33,7 +33,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.DriedRose;
import com.shatteredpixel.shatteredpixeldungeon.items.artifacts.TimekeepersHourglass;
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.WeakFloorRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom;
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;

View File

@ -5,7 +5,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Patch;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;

View File

@ -26,13 +26,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
//TODO figure out where this should go, tunnel room type perhaps?
public class MazeRoom extends Room {
public void paint( Level level, Room room ) {
Painter.fill(level, room, 1, Terrain.EMPTY);
public void paint( Level level ) {
Painter.fill(level, this, 1, Terrain.EMPTY);
//true = space, false = wall
boolean[][] maze = new boolean[room.width()][room.height()];
boolean[][] maze = new boolean[width()][height()];
for (int x = 0; x < maze.length; x++) {
for (int y = 0; y < maze[0].length; y++) {
@ -40,8 +41,8 @@ public class MazeRoom extends Room {
y == 0 || y == maze[0].length - 1) {
//set spaces where there are doors
for (Room.Door d : room.connected.values()) {
if (d.x == x + room.left && d.y == y + room.top) {
for (Door d : connected.values()) {
if (d.x == x + left && d.y == y + top) {
maze[x][y] = true;
break;
}
@ -82,11 +83,11 @@ public class MazeRoom extends Room {
}
Painter.fill(level, room, 1, Terrain.EMPTY);
Painter.fill(level, this, 1, Terrain.EMPTY);
for (int x = 0; x < maze.length; x++)
for (int y = 0; y < maze[0].length; y++) {
if (!maze[x][y]) {
Painter.fill(level, x + room.left, y + room.top, 1, 1, Terrain.WALL);
Painter.fill(level, x + left, y + top, 1, 1, Terrain.WALL);
}
}
}

View File

@ -22,6 +22,20 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ArmoryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.CryptRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.GardenRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LaboratoryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.LibraryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.MagicWellRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.PoolRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StatueRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.StorageRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TrapsRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.TreasuryRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.VaultRoom;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.WeakFloorRoom;
import com.watabou.utils.Bundlable;
import com.watabou.utils.Bundle;
import com.watabou.utils.Graph;
@ -34,6 +48,8 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
//Note that this class should be treated as if it were abstract
// it is currently not abstract to maintain compatibility with pre-0.6.0 saves
public class Room extends Rect implements Graph.Node, Bundlable {
public ArrayList<Room> neigbours = new ArrayList<Room>();
@ -66,6 +82,14 @@ public class Room extends Rect implements Graph.Node, Bundlable {
return this;
}
public int minDimension(){
return -1;
}
public int maxDimension(){
return -1;
}
//Width and height are increased by 1 because rooms are inclusive to their right and bottom sides
@Override
public int width() {
@ -82,15 +106,13 @@ public class Room extends Rect implements Graph.Node, Bundlable {
return width()*height();
}
public void paint(Level level){
paint(level, this);
}
public void paint(Level level){ }
public void paint(Level level, Room room){
}
private static final ArrayList<Class<? extends Room>> ALL_SPEC = new ArrayList<>( Arrays.asList(
private static final ArrayList<Class<? extends SpecialRoom>> 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
) );
@ -126,10 +148,6 @@ public class Room extends Rect implements Graph.Node, Bundlable {
}
}
public Door entrance() {
return connected.values().iterator().next();
}
public boolean inside( Point p ) {
return p.x > left && p.y > top && p.x < right && p.y < bottom;
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
@ -29,22 +29,22 @@ import com.watabou.utils.Point;
//import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.SacrificialFire;
public class AltarRoom extends Room {
public class AltarRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Dungeon.bossLevel( Dungeon.depth + 1 ) ? Terrain.HIGH_GRASS : Terrain.CHASM );
Point c = room.center();
Room.Door door = room.entrance();
if (door.x == room.left || door.x == room.right) {
Point p = Painter.drawInside( level, room, door, Math.abs( door.x - c.x ) - 2, Terrain.EMPTY_SP );
Point c = center();
Door door = entrance();
if (door.x == left || door.x == right) {
Point p = Painter.drawInside( level, this, door, Math.abs( door.x - c.x ) - 2, Terrain.EMPTY_SP );
for (; p.y != c.y; p.y += p.y < c.y ? +1 : -1) {
Painter.set( level, p, Terrain.EMPTY_SP );
}
} else {
Point p = Painter.drawInside( level, room, door, Math.abs( door.y - c.y ) - 2, Terrain.EMPTY_SP );
Point p = Painter.drawInside( level, this, door, Math.abs( door.y - c.y ) - 2, Terrain.EMPTY_SP );
for (; p.x != c.x; p.x += p.x < c.x ? +1 : -1) {
Painter.set( level, p, Terrain.EMPTY_SP );
}
@ -61,6 +61,6 @@ public class AltarRoom extends Room {
fire.seed( c.x + c.y * Level.WIDTH, 5 + Dungeon.depth * 5 );
level.blobs.put( SacrificialFire.class, fire );*/
door.set( Room.Door.Type.EMPTY );
door.set( Door.Type.EMPTY );
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Bomb;
@ -32,23 +32,23 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class ArmoryRoom extends Room {
public class ArmoryRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Room.Door entrance = room.entrance();
Door entrance = entrance();
Point statue = null;
if (entrance.x == room.left) {
statue = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 );
} else if (entrance.x == room.right) {
statue = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top+1 : room.bottom-1 );
} else if (entrance.y == room.top) {
statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.bottom-1 );
} else if (entrance.y == room.bottom) {
statue = new Point( Random.Int( 2 ) == 0 ? room.left+1 : room.right-1, room.top+1 );
if (entrance.x == left) {
statue = new Point( right-1, Random.Int( 2 ) == 0 ? top+1 : bottom-1 );
} else if (entrance.x == right) {
statue = new Point( left+1, Random.Int( 2 ) == 0 ? top+1 : bottom-1 );
} else if (entrance.y == top) {
statue = new Point( Random.Int( 2 ) == 0 ? left+1 : right-1, bottom-1 );
} else if (entrance.y == bottom) {
statue = new Point( Random.Int( 2 ) == 0 ? left+1 : right-1, top+1 );
}
if (statue != null) {
Painter.set( level, statue, Terrain.STATUE );
@ -58,12 +58,12 @@ public class ArmoryRoom extends Room {
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null);
level.drop( prize( level ), pos );
}
entrance.set( Room.Door.Type.LOCKED );
entrance.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -30,18 +30,18 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class BlacksmithRoom extends Room {
public class BlacksmithRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.TRAP );
Painter.fill( level, room, 2, Terrain.EMPTY_SP );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.TRAP );
Painter.fill( level, this, 2, Terrain.EMPTY_SP );
for (int i=0; i < 2; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP);
level.drop(
Generator.random( Random.oneOf(
@ -50,18 +50,18 @@ public class BlacksmithRoom extends Room {
) ), pos );
}
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.UNLOCKED );
Painter.drawInside( level, room, door, 1, Terrain.EMPTY );
for (Door door : connected.values()) {
door.set( Door.Type.UNLOCKED );
Painter.drawInside( level, this, door, 1, Terrain.EMPTY );
}
Blacksmith npc = new Blacksmith();
do {
npc.pos = level.pointToCell(room.random( 1 ));
npc.pos = level.pointToCell(random( 1 ));
} while (level.heaps.get( npc.pos ) != null);
level.mobs.add( npc );
for(Point p : room.getPoints()) {
for(Point p : getPoints()) {
int cell = level.pointToCell(p);
if (level.map[cell] == Terrain.TRAP){
level.setTrap(new FireTrap().reveal(), cell);

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -32,38 +32,38 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
public class CryptRoom extends Room {
public class CryptRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Point c = room.center();
Point c = center();
int cx = c.x;
int cy = c.y;
Room.Door entrance = room.entrance();
Door entrance = entrance();
entrance.set( Room.Door.Type.LOCKED );
entrance.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
if (entrance.x == room.left) {
Painter.set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE );
Painter.set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE );
cx = room.right - 2;
} else if (entrance.x == room.right) {
Painter.set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE );
Painter.set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE );
cx = room.left + 2;
} else if (entrance.y == room.top) {
Painter.set( level, new Point( room.left+1, room.bottom-1 ), Terrain.STATUE );
Painter.set( level, new Point( room.right-1, room.bottom-1 ), Terrain.STATUE );
cy = room.bottom - 2;
} else if (entrance.y == room.bottom) {
Painter.set( level, new Point( room.left+1, room.top+1 ), Terrain.STATUE );
Painter.set( level, new Point( room.right-1, room.top+1 ), Terrain.STATUE );
cy = room.top + 2;
if (entrance.x == left) {
Painter.set( level, new Point( right-1, top+1 ), Terrain.STATUE );
Painter.set( level, new Point( right-1, bottom-1 ), Terrain.STATUE );
cx = right - 2;
} else if (entrance.x == right) {
Painter.set( level, new Point( left+1, top+1 ), Terrain.STATUE );
Painter.set( level, new Point( left+1, bottom-1 ), Terrain.STATUE );
cx = left + 2;
} else if (entrance.y == top) {
Painter.set( level, new Point( left+1, bottom-1 ), Terrain.STATUE );
Painter.set( level, new Point( right-1, bottom-1 ), Terrain.STATUE );
cy = bottom - 2;
} else if (entrance.y == bottom) {
Painter.set( level, new Point( left+1, top+1 ), Terrain.STATUE );
Painter.set( level, new Point( right-1, top+1 ), Terrain.STATUE );
cy = top + 2;
}
level.drop( prize( level ), cx + cy * level.width() ).type = Heap.Type.TOMB;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Challenges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -31,32 +31,32 @@ import com.shatteredpixel.shatteredpixeldungeon.plants.BlandfruitBush;
import com.shatteredpixel.shatteredpixeldungeon.plants.Sungrass;
import com.watabou.utils.Random;
public class GardenRoom extends Room {
public class GardenRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.HIGH_GRASS );
Painter.fill( level, room, 2, Terrain.GRASS );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.HIGH_GRASS );
Painter.fill( level, this, 2, Terrain.GRASS );
room.entrance().set( Room.Door.Type.REGULAR );
entrance().set( Door.Type.REGULAR );
if (Dungeon.isChallenged(Challenges.NO_FOOD)) {
if (Random.Int(2) == 0){
level.plant(new Sungrass.Seed(), level.pointToCell(room.random()));
level.plant(new Sungrass.Seed(), level.pointToCell(random()));
}
} else {
int bushes = Random.Int(3);
if (bushes == 0) {
level.plant(new Sungrass.Seed(), level.pointToCell(room.random()));
level.plant(new Sungrass.Seed(), level.pointToCell(random()));
} else if (bushes == 1) {
level.plant(new BlandfruitBush.Seed(), level.pointToCell(room.random()));
level.plant(new BlandfruitBush.Seed(), level.pointToCell(random()));
} else if (Random.Int(5) == 0) {
int plant1, plant2;
plant1 = level.pointToCell(room.random());
plant1 = level.pointToCell(random());
level.plant(new Sungrass.Seed(), plant1);
do {
plant2 = level.pointToCell(room.random());
plant2 = level.pointToCell(random());
} while (plant2 == plant1);
level.plant(new BlandfruitBush.Seed(), plant2);
}
@ -66,8 +66,8 @@ public class GardenRoom extends Room {
if (light == null) {
light = new Foliage();
}
for (int i=room.top + 1; i < room.bottom; i++) {
for (int j=room.left + 1; j < room.right; j++) {
for (int i=top + 1; i < bottom; i++) {
for (int j=left + 1; j < right; j++) {
light.seed( level, j + level.width() * i, 1 );
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Alchemy;
@ -33,24 +33,24 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class LaboratoryRoom extends Room {
public class LaboratoryRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
Room.Door entrance = room.entrance();
Door entrance = entrance();
Point pot = null;
if (entrance.x == room.left) {
pot = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
} else if (entrance.x == room.right) {
pot = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
} else if (entrance.y == room.top) {
pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 );
} else if (entrance.y == room.bottom) {
pot = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 );
if (entrance.x == left) {
pot = new Point( right-1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
} else if (entrance.x == right) {
pot = new Point( left+1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
} else if (entrance.y == top) {
pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 );
} else if (entrance.y == bottom) {
pot = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+1 );
}
Painter.set( level, pot, Terrain.ALCHEMY );
@ -62,14 +62,14 @@ public class LaboratoryRoom extends Room {
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (
level.map[pos] != Terrain.EMPTY_SP ||
level.heaps.get( pos ) != null);
level.drop( prize( level ), pos );
}
entrance.set( Room.Door.Type.LOCKED );
entrance.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -34,19 +34,19 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class LibraryRoom extends Room {
public class LibraryRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
Room.Door entrance = room.entrance();
Door entrance = entrance();
Point a = null;
Point b = null;
Painter.fill( level, room.left + 1, room.top+1, room.width() - 2, 1 , Terrain.BOOKSHELF );
if (entrance.y == room.top){
Painter.fill( level, left + 1, top+1, width() - 2, 1 , Terrain.BOOKSHELF );
if (entrance.y == top){
Painter.set( level, entrance.x, entrance.y + 1, Terrain.EMPTY_SP );
}
@ -54,7 +54,7 @@ public class LibraryRoom extends Room {
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get( pos ) != null);
Item item;
if (i == 0)
@ -64,7 +64,7 @@ public class LibraryRoom extends Room {
level.drop( item, pos );
}
entrance.set( Room.Door.Type.LOCKED );
entrance.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@ -33,17 +33,17 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class MagicWellRoom extends Room {
public class MagicWellRoom extends SpecialRoom {
private static final Class<?>[] WATERS =
{WaterOfAwareness.class, WaterOfHealth.class, WaterOfTransmutation.class};
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Point c = room.center();
Point c = center();
Painter.set( level, c.x, c.y, Terrain.WELL );
@SuppressWarnings("unchecked")
@ -68,6 +68,6 @@ public class MagicWellRoom extends Room {
water.seed( level, c.x + level.width() * c.y, 1 );
level.blobs.put( waterClass, water );
room.entrance().set( Room.Door.Type.REGULAR );
entrance().set( Door.Type.REGULAR );
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Skeleton;
@ -39,20 +39,20 @@ import com.watabou.utils.Random;
import java.util.ArrayList;
public class MassGraveRoom extends Room {
public class MassGraveRoom extends SpecialRoom {
public void paint( Level level, Room room){
public void paint( Level level){
Room.Door entrance = room.entrance();
entrance.set(Room.Door.Type.BARRICADE);
Door entrance = entrance();
entrance.set(Door.Type.BARRICADE);
level.addItemToSpawn(new PotionOfLiquidFlame());
Painter.fill(level, room, Terrain.WALL);
Painter.fill(level, room, 1, Terrain.EMPTY_SP);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY_SP);
Bones b = new Bones();
b.setRect(room.left+1, room.top, room.width()-2, room.height()-1);
b.setRect(left+1, top, width()-2, height()-1);
level.customTiles.add(b);
//50% 1 skeleton, 50% 2 skeletons
@ -61,7 +61,7 @@ public class MassGraveRoom extends Room {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.findMob(pos) != null);
skele.pos = pos;
level.mobs.add( skele );
@ -80,7 +80,7 @@ public class MassGraveRoom extends Room {
for (Item item : items){
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
Heap h = level.drop(item, pos);
h.type = Heap.Type.SKELETON;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -32,31 +32,31 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class PitRoom extends Room {
public class PitRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Room.Door entrance = room.entrance();
entrance.set( Room.Door.Type.LOCKED );
Door entrance = entrance();
entrance.set( Door.Type.LOCKED );
Point well = null;
if (entrance.x == room.left) {
well = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
} else if (entrance.x == room.right) {
well = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 1 : room.bottom - 1 );
} else if (entrance.y == room.top) {
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 );
} else if (entrance.y == room.bottom) {
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+1 );
if (entrance.x == left) {
well = new Point( right-1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
} else if (entrance.x == right) {
well = new Point( left+1, Random.Int( 2 ) == 0 ? top + 1 : bottom - 1 );
} else if (entrance.y == top) {
well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 );
} else if (entrance.y == bottom) {
well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+1 );
}
Painter.set( level, well, Terrain.EMPTY_WELL );
int remains = level.pointToCell(room.random());
int remains = level.pointToCell(random());
while (level.map[remains] == Terrain.EMPTY_WELL) {
remains = level.pointToCell(room.random());
remains = level.pointToCell(random());
}
level.drop( new IronKey( Dungeon.depth ), remains ).type = Heap.Type.SKELETON;

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Piranha;
@ -33,39 +33,39 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
public class PoolRoom extends Room {
public class PoolRoom extends SpecialRoom {
private static final int NPIRANHAS = 3;
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.WATER );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.WATER );
Room.Door door = room.entrance();
door.set( Room.Door.Type.REGULAR );
Door door = entrance();
door.set( Door.Type.REGULAR );
int x = -1;
int y = -1;
if (door.x == room.left) {
if (door.x == left) {
x = room.right - 1;
y = room.top + room.height() / 2;
x = right - 1;
y = top + height() / 2;
} else if (door.x == room.right) {
} else if (door.x == right) {
x = room.left + 1;
y = room.top + room.height() / 2;
x = left + 1;
y = top + height() / 2;
} else if (door.y == room.top) {
} else if (door.y == top) {
x = room.left + room.width() / 2;
y = room.bottom - 1;
x = left + width() / 2;
y = bottom - 1;
} else if (door.y == room.bottom) {
} else if (door.y == bottom) {
x = room.left + room.width() / 2;
y = room.top + 1;
x = left + width() / 2;
y = top + 1;
}
@ -79,7 +79,7 @@ public class PoolRoom extends Room {
for (int i=0; i < NPIRANHAS; i++) {
Piranha piranha = new Piranha();
do {
piranha.pos = level.pointToCell(room.random());
piranha.pos = level.pointToCell(random());
} while (level.map[piranha.pos] != Terrain.WATER|| level.findMob( piranha.pos ) != null);
level.mobs.add( piranha );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.RatKing;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
@ -30,29 +30,29 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
public class RatKingRoom extends Room {
public class RatKingRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
Room.Door entrance = room.entrance();
entrance.set( Room.Door.Type.HIDDEN );
Door entrance = entrance();
entrance.set( Door.Type.HIDDEN );
int door = entrance.x + entrance.y * level.width();
for (int i=room.left + 1; i < room.right; i++) {
addChest( level, (room.top + 1) * level.width() + i, door );
addChest( level, (room.bottom - 1) * level.width() + i, door );
for (int i=left + 1; i < right; i++) {
addChest( level, (top + 1) * level.width() + i, door );
addChest( level, (bottom - 1) * level.width() + i, door );
}
for (int i=room.top + 2; i < room.bottom - 1; i++) {
addChest( level, i * level.width() + room.left + 1, door );
addChest( level, i * level.width() + room.right - 1, door );
for (int i=top + 2; i < bottom - 1; i++) {
addChest( level, i * level.width() + left + 1, door );
addChest( level, i * level.width() + right - 1, door );
}
RatKing king = new RatKing();
king.pos = level.pointToCell(room.random( 1 ));
king.pos = level.pointToCell(random( 1 ));
level.mobs.add( king );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
@ -32,39 +32,39 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class RotGardenRoom extends Room {
public class RotGardenRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Room.Door entrance = room.entrance();
entrance.set(Room.Door.Type.LOCKED);
Door entrance = entrance();
entrance.set(Door.Type.LOCKED);
level.addItemToSpawn(new IronKey(Dungeon.depth));
Painter.fill(level, room, Terrain.WALL);
Painter.fill(level, room, 1, Terrain.GRASS);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.GRASS);
int heartX = Random.IntRange(room.left+1, room.right-1);
int heartY = Random.IntRange(room.top+1, room.bottom-1);
int heartX = Random.IntRange(left+1, right-1);
int heartY = Random.IntRange(top+1, bottom-1);
if (entrance.x == room.left) {
heartX = room.right - 1;
} else if (entrance.x == room.right) {
heartX = room.left + 1;
} else if (entrance.y == room.top) {
heartY = room.bottom - 1;
} else if (entrance.y == room.bottom) {
heartY = room.top + 1;
if (entrance.x == left) {
heartX = right - 1;
} else if (entrance.x == right) {
heartX = left + 1;
} else if (entrance.y == top) {
heartY = bottom - 1;
} else if (entrance.y == bottom) {
heartY = top + 1;
}
placePlant(level, heartX + heartY * level.width(), new RotHeart());
int lashers = ((room.width()-2)*(room.height()-2))/8;
int lashers = ((width()-2)*(height()-2))/8;
for (int i = 1; i <= lashers; i++){
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (!validPlantPos(level, pos));
placePlant(level, pos, new RotLasher());
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
@ -70,6 +70,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.LastShopLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.plants.Plant;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Point;
@ -78,34 +79,34 @@ import com.watabou.utils.Random;
import java.util.ArrayList;
import java.util.Collections;
public class ShopRoom extends Room {
public class ShopRoom extends SpecialRoom {
private static int pasWidth;
private static int pasHeight;
private static ArrayList<Item> itemsToSpawn;
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
pasWidth = room.width() - 3;
pasHeight = room.height() - 3;
pasWidth = width() - 3;
pasHeight = height() - 3;
int per = pasWidth * 2 + pasHeight * 2;
if (itemsToSpawn == null)
generateItems();
int pos = xy2p( room, room.entrance() ) + (per - itemsToSpawn.size()) / 2;
int pos = xy2p( this, entrance() ) + (per - itemsToSpawn.size()) / 2;
for (Item item : itemsToSpawn) {
Point xy = p2xy( room, (pos + per) % per );
Point xy = p2xy( this, (pos + per) % per );
int cell = xy.x + xy.y * level.width();
if (level.heaps.get( cell ) != null) {
do {
cell = level.pointToCell(room.random());
cell = level.pointToCell(random());
} while (level.heaps.get( cell ) != null);
}
@ -114,10 +115,10 @@ public class ShopRoom extends Room {
pos++;
}
placeShopkeeper( level, room );
placeShopkeeper( level, this );
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.REGULAR );
for (Door door : connected.values()) {
door.set( Door.Type.REGULAR );
}
itemsToSpawn = null;

View File

@ -0,0 +1,20 @@
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
public class SpecialRoom extends Room {
@Override
public int minDimension() {
return 5;
}
@Override
public int maxDimension() {
return 10;
}
public Door entrance() {
return connected.values().iterator().next();
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Statue;
@ -29,41 +29,41 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Point;
public class StatueRoom extends Room {
public class StatueRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Point c = room.center();
Point c = center();
int cx = c.x;
int cy = c.y;
Room.Door door = room.entrance();
Door door = entrance();
door.set( Room.Door.Type.LOCKED );
door.set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
if (door.x == room.left) {
if (door.x == left) {
Painter.fill( level, room.right - 1, room.top + 1, 1, room.height() - 2 , Terrain.STATUE );
cx = room.right - 2;
Painter.fill( level, right - 1, top + 1, 1, height() - 2 , Terrain.STATUE );
cx = right - 2;
} else if (door.x == room.right) {
} else if (door.x == right) {
Painter.fill( level, room.left + 1, room.top + 1, 1, room.height() - 2 , Terrain.STATUE );
cx = room.left + 2;
Painter.fill( level, left + 1, top + 1, 1, height() - 2 , Terrain.STATUE );
cx = left + 2;
} else if (door.y == room.top) {
} else if (door.y == top) {
Painter.fill( level, room.left + 1, room.bottom - 1, room.width() - 2, 1 , Terrain.STATUE );
cy = room.bottom - 2;
Painter.fill( level, left + 1, bottom - 1, width() - 2, 1 , Terrain.STATUE );
cy = bottom - 2;
} else if (door.y == room.bottom) {
} else if (door.y == bottom) {
Painter.fill( level, room.left + 1, room.top + 1, room.width() - 2, 1 , Terrain.STATUE );
cy = room.top + 2;
Painter.fill( level, left + 1, top + 1, width() - 2, 1 , Terrain.STATUE );
cy = top + 2;
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot;
@ -30,14 +30,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
public class StorageRoom extends Room {
public class StorageRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
final int floor = Terrain.EMPTY_SP;
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, floor );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, floor );
boolean honeyPot = Random.Int( 2 ) == 0;
@ -45,7 +45,7 @@ public class StorageRoom extends Room {
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != floor);
if (honeyPot){
level.drop( new Honeypot(), pos);
@ -54,7 +54,7 @@ public class StorageRoom extends Room {
level.drop( prize( level ), pos );
}
room.entrance().set( Room.Door.Type.BARRICADE );
entrance().set( Door.Type.BARRICADE );
level.addItemToSpawn( new PotionOfLiquidFlame() );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon;
@ -48,11 +48,11 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class TrapsRoom extends Room {
public class TrapsRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, this, Terrain.WALL );
Class<? extends Trap> trapClass;
switch (Random.Int(5)){
@ -68,37 +68,37 @@ public class TrapsRoom extends Room {
}
if (trapClass == null){
Painter.fill(level, room, 1, Terrain.CHASM);
Painter.fill(level, this, 1, Terrain.CHASM);
} else {
Painter.fill(level, room, 1, Terrain.TRAP);
Painter.fill(level, this, 1, Terrain.TRAP);
}
Room.Door door = room.entrance();
door.set( Room.Door.Type.REGULAR );
Door door = entrance();
door.set( Door.Type.REGULAR );
int lastRow = level.map[room.left + 1 + (room.top + 1) * level.width()] == Terrain.CHASM ? Terrain.CHASM : Terrain.EMPTY;
int lastRow = level.map[left + 1 + (top + 1) * level.width()] == Terrain.CHASM ? Terrain.CHASM : Terrain.EMPTY;
int x = -1;
int y = -1;
if (door.x == room.left) {
x = room.right - 1;
y = room.top + room.height() / 2;
Painter.fill( level, x, room.top + 1, 1, room.height() - 2 , lastRow );
} else if (door.x == room.right) {
x = room.left + 1;
y = room.top + room.height() / 2;
Painter.fill( level, x, room.top + 1, 1, room.height() - 2 , lastRow );
} else if (door.y == room.top) {
x = room.left + room.width() / 2;
y = room.bottom - 1;
Painter.fill( level, room.left + 1, y, room.width() - 2, 1 , lastRow );
} else if (door.y == room.bottom) {
x = room.left + room.width() / 2;
y = room.top + 1;
Painter.fill( level, room.left + 1, y, room.width() - 2, 1 , lastRow );
if (door.x == left) {
x = right - 1;
y = top + height() / 2;
Painter.fill( level, x, top + 1, 1, height() - 2 , lastRow );
} else if (door.x == right) {
x = left + 1;
y = top + height() / 2;
Painter.fill( level, x, top + 1, 1, height() - 2 , lastRow );
} else if (door.y == top) {
x = left + width() / 2;
y = bottom - 1;
Painter.fill( level, left + 1, y, width() - 2, 1 , lastRow );
} else if (door.y == bottom) {
x = left + width() / 2;
y = top + 1;
Painter.fill( level, left + 1, y, width() - 2, 1 , lastRow );
}
for(Point p : room.getPoints()) {
for(Point p : getPoints()) {
int cell = level.pointToCell(p);
if (level.map[cell] == Terrain.TRAP){
try {

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Gold;
@ -30,14 +30,14 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.Random;
public class TreasuryRoom extends Room {
public class TreasuryRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
Painter.set( level, room.center(), Terrain.STATUE );
Painter.set( level, center(), Terrain.STATUE );
Heap.Type heapType = Random.Int( 2 ) == 0 ? Heap.Type.CHEST : Heap.Type.HEAP;
@ -45,7 +45,7 @@ public class TreasuryRoom extends Room {
for (int i=0; i < n; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY || level.heaps.get( pos ) != null);
level.drop( new Gold().random(), pos ).type = (Random.Int(20) == 0 && heapType == Heap.Type.CHEST ? Heap.Type.MIMIC : heapType);
}
@ -54,13 +54,13 @@ public class TreasuryRoom extends Room {
for (int i=0; i < 6; i++) {
int pos;
do {
pos = level.pointToCell(room.random());
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY);
level.drop( new Gold( Random.IntRange( 5, 12 ) ), pos );
}
}
room.entrance().set( Room.Door.Type.LOCKED );
entrance().set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -33,16 +33,16 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.watabou.utils.PathFinder;
import com.watabou.utils.Random;
public class VaultRoom extends Room {
public class VaultRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY_SP );
Painter.fill( level, room, 2, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY_SP );
Painter.fill( level, this, 2, Terrain.EMPTY );
int cx = (room.left + room.right) / 2;
int cy = (room.top + room.bottom) / 2;
int cx = (left + right) / 2;
int cy = (top + bottom) / 2;
int c = cx + cy * level.width();
switch (Random.Int( 3 )) {
@ -69,7 +69,7 @@ public class VaultRoom extends Room {
break;
}
room.entrance().set( Room.Door.Type.LOCKED );
entrance().set( Door.Type.LOCKED );
level.addItemToSpawn( new IronKey( Dungeon.depth ) );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
@ -31,43 +31,43 @@ import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class WeakFloorRoom extends Room {
public class WeakFloorRoom extends SpecialRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.CHASM );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.CHASM );
Room.Door door = room.entrance();
door.set( Room.Door.Type.REGULAR );
Door door = entrance();
door.set( Door.Type.REGULAR );
if (door.x == room.left) {
for (int i=room.top + 1; i < room.bottom; i++) {
Painter.drawInside( level, room, new Point( room.left, i ), Random.IntRange( 1, room.width() - 3 ), Terrain.EMPTY_SP );
if (door.x == left) {
for (int i=top + 1; i < bottom; i++) {
Painter.drawInside( level, this, new Point( left, i ), Random.IntRange( 1, width() - 3 ), Terrain.EMPTY_SP );
}
} else if (door.x == room.right) {
for (int i=room.top + 1; i < room.bottom; i++) {
Painter.drawInside( level, room, new Point( room.right, i ), Random.IntRange( 1, room.width() - 3 ), Terrain.EMPTY_SP );
} else if (door.x == right) {
for (int i=top + 1; i < bottom; i++) {
Painter.drawInside( level, this, new Point( right, i ), Random.IntRange( 1, width() - 3 ), Terrain.EMPTY_SP );
}
} else if (door.y == room.top) {
for (int i=room.left + 1; i < room.right; i++) {
Painter.drawInside( level, room, new Point( i, room.top ), Random.IntRange( 1, room.height() - 3 ), Terrain.EMPTY_SP );
} else if (door.y == top) {
for (int i=left + 1; i < right; i++) {
Painter.drawInside( level, this, new Point( i, top ), Random.IntRange( 1, height() - 3 ), Terrain.EMPTY_SP );
}
} else if (door.y == room.bottom) {
for (int i=room.left + 1; i < room.right; i++) {
Painter.drawInside( level, room, new Point( i, room.bottom ), Random.IntRange( 1, room.height() - 3 ), Terrain.EMPTY_SP );
} else if (door.y == bottom) {
for (int i=left + 1; i < right; i++) {
Painter.drawInside( level, this, new Point( i, bottom ), Random.IntRange( 1, height() - 3 ), Terrain.EMPTY_SP );
}
}
Point well = null;
if (door.x == room.left) {
well = new Point( room.right-1, Random.Int( 2 ) == 0 ? room.top + 2 : room.bottom - 1 );
} else if (door.x == room.right) {
well = new Point( room.left+1, Random.Int( 2 ) == 0 ? room.top + 2 : room.bottom - 1 );
} else if (door.y == room.top) {
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.bottom-1 );
} else if (door.y == room.bottom) {
well = new Point( Random.Int( 2 ) == 0 ? room.left + 1 : room.right - 1, room.top+2 );
if (door.x == left) {
well = new Point( right-1, Random.Int( 2 ) == 0 ? top + 2 : bottom - 1 );
} else if (door.x == right) {
well = new Point( left+1, Random.Int( 2 ) == 0 ? top + 2 : bottom - 1 );
} else if (door.y == top) {
well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, bottom-1 );
} else if (door.y == bottom) {
well = new Point( Random.Int( 2 ) == 0 ? left + 1 : right - 1, top+2 );
}
Painter.set(level, well, Terrain.CHASM);
CustomTiledVisual vis = new HiddenWell();

View File

@ -19,25 +19,26 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
public class EntranceRoom extends Room {
public class EntranceRoom extends StandardRoom {
public void paint( Level level, Room room ) {
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
for (Room.Door door : room.connected.values()) {
for (Room.Door door : connected.values()) {
door.set( Room.Door.Type.REGULAR );
}
do {
level.entrance = level.pointToCell(room.random(1));
level.entrance = level.pointToCell(random(1));
} while (level.findMob(level.entrance) != null);
Painter.set( level, level.entrance, Terrain.ENTRANCE );
}

View File

@ -19,24 +19,25 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
public class ExitRoom extends Room {
public class ExitRoom extends StandardRoom {
public void paint( Level level, Room room ) {
public void paint( Level level) {
Painter.fill( level, room, Terrain.WALL );
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, Terrain.WALL );
Painter.fill( level, this, 1, Terrain.EMPTY );
for (Room.Door door : room.connected.values()) {
for (Room.Door door : connected.values()) {
door.set( Room.Door.Type.REGULAR );
}
level.exit = level.pointToCell(room.random( 1 ));
level.exit = level.pointToCell(random( 1 ));
Painter.set( level, level.exit, Terrain.EXIT );
}

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle;
@ -30,19 +30,19 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTiledVisual;
import com.watabou.utils.Point;
public class RitualSiteRoom extends Room {
public class RitualSiteRoom extends StandardRoom {
public void paint( Level level, Room room) {
public void paint( Level level ) {
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.REGULAR );
for (Door door : connected.values()) {
door.set( Door.Type.REGULAR );
}
Painter.fill(level, room, Terrain.WALL);
Painter.fill(level, room, 1, Terrain.EMPTY);
Painter.fill(level, this, Terrain.WALL);
Painter.fill(level, this, 1, Terrain.EMPTY);
RitualMarker vis = new RitualMarker();
Point c = room.center();
Point c = center();
vis.pos(c.x - 1, c.y - 1);
level.customTiles.add(vis);

View File

@ -19,7 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
@ -29,25 +29,36 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.FireTrap;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class StandardRoom extends Room {
public void paint( Level level, Room room ) {
@Override
public int minDimension() {
return 4;
}
@Override
public int maxDimension() {
return 10;
}
public void paint( Level level ) {
Painter.fill( level, room, Terrain.WALL );
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.REGULAR );
Painter.fill( level, this, Terrain.WALL );
for (Door door : connected.values()) {
door.set( Door.Type.REGULAR );
}
if (!Dungeon.bossLevel() && Random.Int( 5 ) == 0) {
switch (Random.Int( 6 )) {
case 0:
if (level.feeling != Level.Feeling.GRASS) {
if (Math.min( room.width(), room.height() ) > 4 && Math.max( room.width(), room.height() ) > 6) {
paintGraveyard( level, room );
if (Math.min( width(), height() ) > 4 && Math.max( width(), height() ) > 6) {
paintGraveyard( level, this );
return;
}
break;
@ -56,26 +67,26 @@ public class StandardRoom extends Room {
}
case 1:
if (Dungeon.depth > 1) {
paintBurned( level, room );
paintBurned( level, this );
return;
}
break;
case 2:
if (Math.max( room.width(), room.height() ) > 4) {
paintStriped( level, room );
if (Math.max( width(), height() ) > 4) {
paintStriped( level, this );
return;
}
break;
case 3:
if (room.width() > 6 && room.height() > 6) {
paintStudy( level, room );
if (width() > 6 && height() > 6) {
paintStudy( level, this );
return;
}
break;
case 4:
if (level.feeling != Level.Feeling.WATER) {
if (room.connected.size() == 2 && room.width() > 4 && room.height() > 4) {
paintBridge( level, room );
if (connected.size() == 2 && width() > 4 && height() > 4) {
paintBridge( level, this );
return;
}
break;
@ -84,15 +95,15 @@ public class StandardRoom extends Room {
}
case 5:
if (!Dungeon.bossLevel() && !Dungeon.bossLevel( Dungeon.depth + 1 ) &&
Math.min( room.width(), room.height() ) > 5) {
paintFissure( level, room );
Math.min( width(), height() ) > 5) {
paintFissure( level, this );
return;
}
break;
}
}
Painter.fill( level, room, 1, Terrain.EMPTY );
Painter.fill( level, this, 1, Terrain.EMPTY );
}
private static void paintBurned( Level level, Room room ) {

View File

@ -19,30 +19,31 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Point;
import java.util.ArrayList;
import java.util.Collections;
public class PassageRoom extends Room {
public class PassageRoom extends TunnelRoom {
private static int pasWidth;
private static int pasHeight;
public void paint( Level level, Room room ) {
public void paint( Level level ) {
pasWidth = room.width() - 3;
pasHeight = room.height() - 3;
pasWidth = width() - 3;
pasHeight = height() - 3;
int floor = level.tunnelTile();
ArrayList<Integer> joints = new ArrayList<Integer>();
for (Point door : room.connected.values()) {
joints.add( xy2p( room, door ) );
for (Point door : connected.values()) {
joints.add( xy2p( this, door ) );
}
Collections.sort( joints );
@ -63,14 +64,14 @@ public class PassageRoom extends Room {
int p = joints.get( start );
do {
Painter.set( level, p2xy( room, p ), floor );
Painter.set( level, p2xy( this, p ), floor );
p = (p + 1) % perimeter;
} while (p != joints.get( end ));
Painter.set( level, p2xy( room, p ), floor );
Painter.set( level, p2xy( this, p ), floor );
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.TUNNEL );
for (Door door : connected.values()) {
door.set( Door.Type.TUNNEL );
}
}

View File

@ -19,40 +19,51 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms;
package com.shatteredpixel.shatteredpixeldungeon.levels.rooms.tunnel;
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room;
import com.watabou.utils.Point;
import com.watabou.utils.Random;
public class TunnelRoom extends Room {
public void paint( Level level, Room room ) {
@Override
public int minDimension() {
return 3;
}
@Override
public int maxDimension() {
return 10;
}
public void paint(Level level) {
int floor = level.tunnelTile();
Point c = room.center();
Point c = center();
if (room.width() > room.height() || (room.width() == room.height() && Random.Int( 2 ) == 0)) {
if (width() > height() || (width() == height() && Random.Int( 2 ) == 0)) {
int from = room.right - 1;
int to = room.left + 1;
int from = right - 1;
int to = left + 1;
for (Room.Door door : room.connected.values()) {
for (Door door : connected.values()) {
int step = door.y < c.y ? +1 : -1;
if (door.x == room.left) {
if (door.x == left) {
from = room.left + 1;
from = left + 1;
for (int i=door.y; i != c.y; i += step) {
Painter.set( level, from, i, floor );
}
} else if (door.x == room.right) {
} else if (door.x == right) {
to = room.right - 1;
to = right - 1;
for (int i=door.y; i != c.y; i += step) {
Painter.set( level, to, i, floor );
}
@ -77,23 +88,23 @@ public class TunnelRoom extends Room {
} else {
int from = room.bottom - 1;
int to = room.top + 1;
int from = bottom - 1;
int to = top + 1;
for (Room.Door door : room.connected.values()) {
for (Door door : connected.values()) {
int step = door.x < c.x ? +1 : -1;
if (door.y == room.top) {
if (door.y == top) {
from = room.top + 1;
from = top + 1;
for (int i=door.x; i != c.x; i += step) {
Painter.set( level, i, from, floor );
}
} else if (door.y == room.bottom) {
} else if (door.y == bottom) {
to = room.bottom - 1;
to = bottom - 1;
for (int i=door.x; i != c.x; i += step) {
Painter.set( level, i, to, floor );
}
@ -117,8 +128,8 @@ public class TunnelRoom extends Room {
}
}
for (Room.Door door : room.connected.values()) {
door.set( Room.Door.Type.TUNNEL );
for (Door door : connected.values()) {
door.set( Door.Type.TUNNEL );
}
}
}