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++){
|
for (int j = area.top; j < area.bottom; j++){
|
||||||
cell = i + j*Dungeon.level.width();
|
cell = i + j*Dungeon.level.width();
|
||||||
if (cur[cell] > 0) {
|
if (cur[cell] > 0) {
|
||||||
int terr = Dungeon.level.map[cell];
|
Dungeon.level.setCellToWater(true, 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,14 +51,7 @@ public class AquaBlast extends TargetedSpell {
|
||||||
|
|
||||||
for (int i : PathFinder.NEIGHBOURS9){
|
for (int i : PathFinder.NEIGHBOURS9){
|
||||||
if (i == 0 || Random.Int(5) != 0){
|
if (i == 0 || Random.Int(5) != 0){
|
||||||
int terr = Dungeon.level.map[cell + i];
|
Dungeon.level.setCellToWater(false, 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -823,6 +823,41 @@ public abstract class Level implements Bundlable {
|
||||||
GameScene.updateMap( cell );
|
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 ) {
|
public int fallCell( boolean fallIntoPit ) {
|
||||||
int result;
|
int result;
|
||||||
do {
|
do {
|
||||||
|
|
|
@ -192,6 +192,17 @@ public class NewCavesBossLevel extends Level {
|
||||||
return cell;
|
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
|
@Override
|
||||||
public void occupyCell(Char ch) {
|
public void occupyCell(Char ch) {
|
||||||
super.occupyCell(ch);
|
super.occupyCell(ch);
|
||||||
|
@ -707,25 +718,28 @@ public class NewCavesBossLevel extends Level {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void evolve() {
|
protected void evolve() {
|
||||||
int cell;
|
for (int cell = 0; cell < Dungeon.level.length(); cell++) {
|
||||||
for (int i=area.top-1; i <= area.bottom; i++) {
|
if (Dungeon.level.insideMap(cell)) {
|
||||||
for (int j = area.left-1; j <= area.right; j++) {
|
off[cell] = cur[cell];
|
||||||
cell = j + i* Dungeon.level.width();
|
|
||||||
if (Dungeon.level.insideMap(cell)) {
|
|
||||||
off[cell] = cur[cell];
|
|
||||||
volume += off[cell];
|
|
||||||
if (off[cell] > 0){
|
|
||||||
|
|
||||||
Char ch = Actor.findChar(cell);
|
//instantly spreads to water cells
|
||||||
if (ch != null && !(ch instanceof NewDM300)) {
|
if (off[cell] == 0 && Dungeon.level.water[cell]){
|
||||||
Sample.INSTANCE.play( Assets.SND_LIGHTNING );
|
off[cell]++;
|
||||||
ch.damage( Random.NormalIntRange(6, 12), Electricity.class);
|
}
|
||||||
ch.sprite.flash();
|
|
||||||
|
|
||||||
if (ch == Dungeon.hero && !ch.isAlive()) {
|
volume += off[cell];
|
||||||
Dungeon.fail(NewDM300.class);
|
|
||||||
GLog.n( Messages.get(Electricity.class, "ondeath") );
|
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, 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,
|
40, 41, 36, 36, 36, 36, 36, 40, 41,
|
||||||
48, 49, 36, 36, 36, 36, 36, 48, 49
|
48, 49, 36, 36, 36, 36, 36, 48, 49
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user