v0.8.0a: improved logic for spreading water to tiles, fixes bugs

This commit is contained in:
Evan Debenham 2020-04-24 23:53:54 -04:00
parent 4c7bf65742
commit bab229ec3d
5 changed files with 69 additions and 38 deletions

View File

@ -41,18 +41,7 @@ public class StormCloud extends Blob {
for (int j = area.top; j < area.bottom; j++){
cell = i + j*Dungeon.level.width();
if (cur[cell] > 0) {
int terr = Dungeon.level.map[cell];
if (terr == Terrain.EMPTY || terr == Terrain.GRASS ||
terr == Terrain.EMBERS || terr == Terrain.EMPTY_SP ||
terr == Terrain.HIGH_GRASS || terr == Terrain.FURROWED_GRASS
|| terr == Terrain.EMPTY_DECO) {
Level.set(cell, Terrain.WATER);
GameScene.updateMap(cell);
} else if (terr == Terrain.SECRET_TRAP || terr == Terrain.TRAP || terr == Terrain.INACTIVE_TRAP) {
Level.set(cell, Terrain.WATER);
Dungeon.level.traps.remove(cell);
GameScene.updateMap(cell);
}
Dungeon.level.setCellToWater(true, cell);
}
}
}

View File

@ -51,14 +51,7 @@ public class AquaBlast extends TargetedSpell {
for (int i : PathFinder.NEIGHBOURS9){
if (i == 0 || Random.Int(5) != 0){
int terr = Dungeon.level.map[cell + i];
if (terr == Terrain.EMPTY || terr == Terrain.GRASS ||
terr == Terrain.EMBERS || terr == Terrain.EMPTY_SP ||
terr == Terrain.HIGH_GRASS || terr == Terrain.FURROWED_GRASS ||
terr == Terrain.EMPTY_DECO) {
Level.set(cell + i, Terrain.WATER);
GameScene.updateMap(cell + i);
}
Dungeon.level.setCellToWater(false, cell+i);
}
}

View File

@ -823,6 +823,41 @@ public abstract class Level implements Bundlable {
GameScene.updateMap( cell );
}
public boolean setCellToWater( boolean includeTraps, int cell ){
Point p = cellToPoint(cell);
//if a custom tilemap is over that cell, don't put water there
for (CustomTilemap cust : customTiles){
Point custPoint = new Point(p);
custPoint.x -= cust.tileX;
custPoint.y -= cust.tileY;
if (custPoint.x >= 0 && custPoint.y >= 0
&& custPoint.x < cust.tileW && custPoint.y < cust.tileH){
if (cust.image(custPoint.x, custPoint.y) != null){
return false;
}
}
}
int terr = map[cell];
if (terr == Terrain.EMPTY || terr == Terrain.GRASS ||
terr == Terrain.EMBERS || terr == Terrain.EMPTY_SP ||
terr == Terrain.HIGH_GRASS || terr == Terrain.FURROWED_GRASS
|| terr == Terrain.EMPTY_DECO){
set(cell, Terrain.WATER);
GameScene.updateMap(cell);
return true;
} else if (includeTraps && (terr == Terrain.SECRET_TRAP ||
terr == Terrain.TRAP || terr == Terrain.INACTIVE_TRAP)){
set(cell, Terrain.WATER);
Dungeon.level.traps.remove(cell);
GameScene.updateMap(cell);
return true;
}
return false;
}
public int fallCell( boolean fallIntoPit ) {
int result;
do {

View File

@ -192,6 +192,17 @@ public class NewCavesBossLevel extends Level {
return cell;
}
@Override
public boolean setCellToWater(boolean includeTraps, int cell) {
for (int i : pylonPositions){
if (Dungeon.level.distance(cell, i) <= 1){
return false;
}
}
return super.setCellToWater(includeTraps, cell);
}
@Override
public void occupyCell(Char ch) {
super.occupyCell(ch);
@ -707,13 +718,17 @@ public class NewCavesBossLevel extends Level {
@Override
protected void evolve() {
int cell;
for (int i=area.top-1; i <= area.bottom; i++) {
for (int j = area.left-1; j <= area.right; j++) {
cell = j + i* Dungeon.level.width();
for (int cell = 0; cell < Dungeon.level.length(); cell++) {
if (Dungeon.level.insideMap(cell)) {
off[cell] = cur[cell];
//instantly spreads to water cells
if (off[cell] == 0 && Dungeon.level.water[cell]){
off[cell]++;
}
volume += off[cell];
if (off[cell] > 0){
Char ch = Actor.findChar(cell);
@ -731,7 +746,6 @@ public class NewCavesBossLevel extends Level {
}
}
}
}
@Override
public void fullyClear() {

View File

@ -283,7 +283,7 @@ public class NewHallsBossLevel extends Level {
24, 25, 26, 19, 19, 19, 28, 29, 30,
24, 25, 26, 19, 19, 19, 28, 29, 30,
24, 25, 26, 19, 19, 19, 28, 29, 30,
24, 25, 34, 35, 35, 35, -1, 29, 30,
24, 25, 34, 35, 35, 35, 34, 29, 30,
40, 41, 36, 36, 36, 36, 36, 40, 41,
48, 49, 36, 36, 36, 36, 36, 48, 49
};