v0.6.0: improved pitfall trap logic
This commit is contained in:
+11
-3
@@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
|||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
|
import com.watabou.utils.PathFinder;
|
||||||
|
|
||||||
public class PitfallTrap extends Trap {
|
public class PitfallTrap extends Trap {
|
||||||
|
|
||||||
@@ -65,10 +66,17 @@ public class PitfallTrap extends Trap {
|
|||||||
protected void disarm() {
|
protected void disarm() {
|
||||||
super.disarm();
|
super.disarm();
|
||||||
|
|
||||||
//if making a pit here wouldn't block any paths, make a pit tile instead of a disarmed trap tile.
|
int stateChanges = 0;
|
||||||
if (!(Dungeon.level.solid[pos - Dungeon.level.width()] && Dungeon.level.solid[pos + Dungeon.level.width()])
|
boolean curPassable = Level.passable[pos + PathFinder.CIRCLE8[PathFinder.CIRCLE8.length-1]];
|
||||||
&& !(Dungeon.level.solid[pos - 1]&& Dungeon.level.solid[pos + 1])){
|
for (int i : PathFinder.CIRCLE8){
|
||||||
|
if (curPassable != Level.passable[pos + i]){
|
||||||
|
stateChanges++;
|
||||||
|
curPassable = Level.passable[pos + i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if making a pit here wouldn't block any paths, make a pit tile instead of a disarmed trap tile.
|
||||||
|
if (stateChanges <= 2){
|
||||||
Level.set(pos, Terrain.CHASM);
|
Level.set(pos, Terrain.CHASM);
|
||||||
GameScene.updateMap( pos );
|
GameScene.updateMap( pos );
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user