v0.6.0: level sizes are now determined within the build method

In the case of regular levels, this happens in the painter
This commit is contained in:
Evan Debenham 2017-03-31 04:21:11 -04:00
parent 0e0554f324
commit 8ec8231504
9 changed files with 57 additions and 46 deletions

View File

@ -268,8 +268,7 @@ public class Dungeon {
level = new DeadEndLevel();
Statistics.deepestFloor--;
}
visible = new boolean[level.length()];
level.create();
Statistics.qualifiedForNoKilling = !bossLevel();

View File

@ -100,6 +100,8 @@ public class CavesBossLevel extends Level {
@Override
protected boolean build() {
setSize(32, 32);
int topMost = Integer.MAX_VALUE;
for (int i=0; i < 8; i++) {

View File

@ -95,6 +95,8 @@ public class CityBossLevel extends Level {
@Override
protected boolean build() {
setSize(32, 32);
Painter.fill( this, LEFT, TOP, HALL_WIDTH, HALL_HEIGHT, Terrain.EMPTY );
Painter.fill( this, CENTER, TOP, 1, HALL_HEIGHT, Terrain.EMPTY_SP );

View File

@ -25,8 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.watabou.utils.Random;
import java.util.Arrays;
public class DeadEndLevel extends Level {
private static final int SIZE = 5;
@ -48,8 +46,8 @@ public class DeadEndLevel extends Level {
@Override
protected boolean build() {
Arrays.fill( map, Terrain.WALL );
setSize(7, 7);
for (int i=2; i < SIZE; i++) {
for (int j=2; j < SIZE; j++) {

View File

@ -94,6 +94,8 @@ public class HallsBossLevel extends Level {
@Override
protected boolean build() {
setSize(32, 32);
for (int i=0; i < 5; i++) {
int top = Random.IntRange( 2, ROOM_TOP - 1 );

View File

@ -44,15 +44,6 @@ public class LastLevel extends Level {
private int pedestal;
@Override
protected void setupSize() {
if (width == 0 || height == 0) {
width = 16;
height = 64;
}
length = width * height;
}
@Override
public String tilesTex() {
return Assets.TILES_HALLS;
@ -77,7 +68,8 @@ public class LastLevel extends Level {
@Override
protected boolean build() {
setSize(16, 64);
Arrays.fill( map, Terrain.CHASM );
int mid = width/2;

View File

@ -179,23 +179,6 @@ public abstract class Level implements Bundlable {
public void create() {
Random.seed( Dungeon.seedCurDepth() );
setupSize();
PathFinder.setMapSize(width(), height());
passable = new boolean[length()];
losBlocking = new boolean[length()];
flamable = new boolean[length()];
secret = new boolean[length()];
solid = new boolean[length()];
avoid = new boolean[length()];
water = new boolean[length()];
pit = new boolean[length()];
map = new int[length()];
visited = new boolean[length()];
Arrays.fill( visited, false );
mapped = new boolean[length()];
Arrays.fill( mapped, false );
if (!(Dungeon.bossLevel() || Dungeon.depth == 21) /*final shop floor*/) {
addItemToSpawn( Generator.random( Generator.Category.FOOD ) );
@ -262,10 +245,9 @@ public abstract class Level implements Bundlable {
boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
do {
Arrays.fill( map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL );
pitRoomNeeded = pitNeeded;
weakFloorCreated = false;
width = height = length = 0;
mobs = new HashSet<>();
heaps = new SparseArray<>();
@ -278,6 +260,16 @@ public abstract class Level implements Bundlable {
} while (!build());
decorate();
PathFinder.setMapSize(width(), height());
passable = new boolean[length()];
losBlocking = new boolean[length()];
flamable = new boolean[length()];
secret = new boolean[length()];
solid = new boolean[length()];
avoid = new boolean[length()];
water = new boolean[length()];
pit = new boolean[length()];
buildFlagMaps();
cleanWalls();
@ -286,11 +278,20 @@ public abstract class Level implements Bundlable {
Random.seed();
}
protected void setupSize(){
if (width == 0 || height == 0)
width = height = 32;
length = width * height;
public void setSize(int w, int h){
width = w;
height = h;
length = w * h;
map = new int[length];
Arrays.fill( map, Terrain.WALL );
Arrays.fill( map, feeling == Level.Feeling.CHASM ? Terrain.CHASM : Terrain.WALL );
visited = new boolean[length];
mapped = new boolean[length];
Dungeon.visible = new boolean[length];
}
public void reset() {
@ -450,20 +451,14 @@ public abstract class Level implements Bundlable {
}
public int width() {
if (width == 0)
setupSize();
return width;
}
public int height() {
if (height == 0)
setupSize();
return height;
}
public int length() {
if (length == 0)
setupSize();
return length;
}

View File

@ -119,6 +119,8 @@ public class PrisonBossLevel extends Level {
@Override
protected boolean build() {
setSize(32, 32);
map = MAP_START.clone();
decorate();

View File

@ -64,6 +64,25 @@ public class RegularPainter extends Painter {
@Override
public boolean paint(Level level, ArrayList<Room> rooms) {
int leftMost = Integer.MAX_VALUE, topMost = Integer.MAX_VALUE;
for (Room r : rooms){
if (r.left < leftMost) leftMost = r.left;
if (r.top < topMost) topMost = r.top;
}
int width = 0, height = 0;
for (Room r : rooms){
r.shift( -leftMost, -topMost);
if (r.right > width) width = r.right;
if (r.bottom > height) height = r.bottom;
}
level.setSize(width+1, height+1);
PathFinder.setMapSize(level.width(), level.height());
for (Room r : rooms) {
placeDoors( r );
r.paint( level );