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:
parent
0e0554f324
commit
8ec8231504
|
@ -268,8 +268,7 @@ public class Dungeon {
|
||||||
level = new DeadEndLevel();
|
level = new DeadEndLevel();
|
||||||
Statistics.deepestFloor--;
|
Statistics.deepestFloor--;
|
||||||
}
|
}
|
||||||
|
|
||||||
visible = new boolean[level.length()];
|
|
||||||
level.create();
|
level.create();
|
||||||
|
|
||||||
Statistics.qualifiedForNoKilling = !bossLevel();
|
Statistics.qualifiedForNoKilling = !bossLevel();
|
||||||
|
|
|
@ -100,6 +100,8 @@ public class CavesBossLevel extends Level {
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
|
setSize(32, 32);
|
||||||
|
|
||||||
int topMost = Integer.MAX_VALUE;
|
int topMost = Integer.MAX_VALUE;
|
||||||
|
|
||||||
for (int i=0; i < 8; i++) {
|
for (int i=0; i < 8; i++) {
|
||||||
|
|
|
@ -95,6 +95,8 @@ public class CityBossLevel extends Level {
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
|
setSize(32, 32);
|
||||||
|
|
||||||
Painter.fill( this, LEFT, TOP, HALL_WIDTH, HALL_HEIGHT, Terrain.EMPTY );
|
Painter.fill( this, LEFT, TOP, HALL_WIDTH, HALL_HEIGHT, Terrain.EMPTY );
|
||||||
Painter.fill( this, CENTER, TOP, 1, HALL_HEIGHT, Terrain.EMPTY_SP );
|
Painter.fill( this, CENTER, TOP, 1, HALL_HEIGHT, Terrain.EMPTY_SP );
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class DeadEndLevel extends Level {
|
public class DeadEndLevel extends Level {
|
||||||
|
|
||||||
private static final int SIZE = 5;
|
private static final int SIZE = 5;
|
||||||
|
@ -48,8 +46,8 @@ public class DeadEndLevel extends Level {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
Arrays.fill( map, Terrain.WALL );
|
setSize(7, 7);
|
||||||
|
|
||||||
for (int i=2; i < SIZE; i++) {
|
for (int i=2; i < SIZE; i++) {
|
||||||
for (int j=2; j < SIZE; j++) {
|
for (int j=2; j < SIZE; j++) {
|
||||||
|
|
|
@ -94,6 +94,8 @@ public class HallsBossLevel extends Level {
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
|
setSize(32, 32);
|
||||||
|
|
||||||
for (int i=0; i < 5; i++) {
|
for (int i=0; i < 5; i++) {
|
||||||
|
|
||||||
int top = Random.IntRange( 2, ROOM_TOP - 1 );
|
int top = Random.IntRange( 2, ROOM_TOP - 1 );
|
||||||
|
|
|
@ -44,15 +44,6 @@ public class LastLevel extends Level {
|
||||||
|
|
||||||
private int pedestal;
|
private int pedestal;
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setupSize() {
|
|
||||||
if (width == 0 || height == 0) {
|
|
||||||
width = 16;
|
|
||||||
height = 64;
|
|
||||||
}
|
|
||||||
length = width * height;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String tilesTex() {
|
public String tilesTex() {
|
||||||
return Assets.TILES_HALLS;
|
return Assets.TILES_HALLS;
|
||||||
|
@ -77,7 +68,8 @@ public class LastLevel extends Level {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
|
setSize(16, 64);
|
||||||
Arrays.fill( map, Terrain.CHASM );
|
Arrays.fill( map, Terrain.CHASM );
|
||||||
|
|
||||||
int mid = width/2;
|
int mid = width/2;
|
||||||
|
|
|
@ -179,23 +179,6 @@ public abstract class Level implements Bundlable {
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
||||||
Random.seed( Dungeon.seedCurDepth() );
|
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*/) {
|
if (!(Dungeon.bossLevel() || Dungeon.depth == 21) /*final shop floor*/) {
|
||||||
addItemToSpawn( Generator.random( Generator.Category.FOOD ) );
|
addItemToSpawn( Generator.random( Generator.Category.FOOD ) );
|
||||||
|
@ -262,10 +245,9 @@ public abstract class Level implements Bundlable {
|
||||||
boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
|
boolean pitNeeded = Dungeon.depth > 1 && weakFloorCreated;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
Arrays.fill( map, feeling == Feeling.CHASM ? Terrain.CHASM : Terrain.WALL );
|
|
||||||
|
|
||||||
pitRoomNeeded = pitNeeded;
|
pitRoomNeeded = pitNeeded;
|
||||||
weakFloorCreated = false;
|
weakFloorCreated = false;
|
||||||
|
width = height = length = 0;
|
||||||
|
|
||||||
mobs = new HashSet<>();
|
mobs = new HashSet<>();
|
||||||
heaps = new SparseArray<>();
|
heaps = new SparseArray<>();
|
||||||
|
@ -278,6 +260,16 @@ public abstract class Level implements Bundlable {
|
||||||
} while (!build());
|
} while (!build());
|
||||||
decorate();
|
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();
|
buildFlagMaps();
|
||||||
cleanWalls();
|
cleanWalls();
|
||||||
|
|
||||||
|
@ -286,11 +278,20 @@ public abstract class Level implements Bundlable {
|
||||||
|
|
||||||
Random.seed();
|
Random.seed();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setupSize(){
|
public void setSize(int w, int h){
|
||||||
if (width == 0 || height == 0)
|
|
||||||
width = height = 32;
|
width = w;
|
||||||
length = width * height;
|
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() {
|
public void reset() {
|
||||||
|
@ -450,20 +451,14 @@ public abstract class Level implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int width() {
|
public int width() {
|
||||||
if (width == 0)
|
|
||||||
setupSize();
|
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int height() {
|
public int height() {
|
||||||
if (height == 0)
|
|
||||||
setupSize();
|
|
||||||
return height;
|
return height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int length() {
|
public int length() {
|
||||||
if (length == 0)
|
|
||||||
setupSize();
|
|
||||||
return length;
|
return length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,8 @@ public class PrisonBossLevel extends Level {
|
||||||
@Override
|
@Override
|
||||||
protected boolean build() {
|
protected boolean build() {
|
||||||
|
|
||||||
|
setSize(32, 32);
|
||||||
|
|
||||||
map = MAP_START.clone();
|
map = MAP_START.clone();
|
||||||
decorate();
|
decorate();
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,25 @@ public class RegularPainter extends Painter {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean paint(Level level, ArrayList<Room> rooms) {
|
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) {
|
for (Room r : rooms) {
|
||||||
placeDoors( r );
|
placeDoors( r );
|
||||||
r.paint( level );
|
r.paint( level );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user