v0.8.0a: improved logic for spreading water to tiles, fixes bugs
This commit is contained in:
parent
4c7bf65742
commit
bab229ec3d
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -822,6 +822,41 @@ public abstract class Level implements Bundlable {
|
|||
trap.reveal();
|
||||
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;
|
||||
|
|
|
@ -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,25 +718,28 @@ 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();
|
||||
if (Dungeon.level.insideMap(cell)) {
|
||||
off[cell] = cur[cell];
|
||||
volume += off[cell];
|
||||
if (off[cell] > 0){
|
||||
for (int cell = 0; cell < Dungeon.level.length(); cell++) {
|
||||
if (Dungeon.level.insideMap(cell)) {
|
||||
off[cell] = cur[cell];
|
||||
|
||||
Char ch = Actor.findChar(cell);
|
||||
if (ch != null && !(ch instanceof NewDM300)) {
|
||||
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
|
||||
ch.damage( Random.NormalIntRange(6, 12), Electricity.class);
|
||||
ch.sprite.flash();
|
||||
//instantly spreads to water cells
|
||||
if (off[cell] == 0 && Dungeon.level.water[cell]){
|
||||
off[cell]++;
|
||||
}
|
||||
|
||||
if (ch == Dungeon.hero && !ch.isAlive()) {
|
||||
Dungeon.fail(NewDM300.class);
|
||||
GLog.n( Messages.get(Electricity.class, "ondeath") );
|
||||
}
|
||||
volume += off[cell];
|
||||
|
||||
if (off[cell] > 0){
|
||||
|
||||
Char ch = Actor.findChar(cell);
|
||||
if (ch != null && !(ch instanceof NewDM300)) {
|
||||
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
|
||||
ch.damage( Random.NormalIntRange(6, 12), Electricity.class);
|
||||
ch.sprite.flash();
|
||||
|
||||
if (ch == Dungeon.hero && !ch.isAlive()) {
|
||||
Dungeon.fail(NewDM300.class);
|
||||
GLog.n( Messages.get(Electricity.class, "ondeath") );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user