diff --git a/assets/tiles0.png b/assets/tiles0.png index 5dfab3d9b..166213a62 100644 Binary files a/assets/tiles0.png and b/assets/tiles0.png differ diff --git a/assets/tiles1.png b/assets/tiles1.png index cfcf3aefd..bf8ff2134 100644 Binary files a/assets/tiles1.png and b/assets/tiles1.png differ diff --git a/assets/tiles2.png b/assets/tiles2.png index f48538955..f748caea2 100644 Binary files a/assets/tiles2.png and b/assets/tiles2.png differ diff --git a/assets/tiles3.png b/assets/tiles3.png index 93a4355a1..a2bcab53c 100644 Binary files a/assets/tiles3.png and b/assets/tiles3.png differ diff --git a/assets/tiles4.png b/assets/tiles4.png index d9a9f502c..80ae455ac 100644 Binary files a/assets/tiles4.png and b/assets/tiles4.png differ diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java index 0afd21096..5c7b32f92 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/CavesBossLevel.java @@ -20,6 +20,8 @@ */ package com.shatteredpixel.shatteredpixeldungeon.levels; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.watabou.noosa.Camera; import com.watabou.noosa.Scene; import com.watabou.noosa.audio.Sample; @@ -120,19 +122,13 @@ public class CavesBossLevel extends Level { map[exit] = Terrain.LOCKED_EXIT; - for (int i=0; i < LENGTH; i++) { - if (map[i] == Terrain.EMPTY && Random.Int( 6 ) == 0) { - map[i] = Terrain.INACTIVE_TRAP; - } - } - Painter.fill( this, ROOM_LEFT - 1, ROOM_TOP - 1, ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL ); Painter.fill( this, ROOM_LEFT, ROOM_TOP + 1, ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP, Terrain.EMPTY ); Painter.fill( this, ROOM_LEFT, ROOM_TOP, - ROOM_RIGHT - ROOM_LEFT + 1, 1, Terrain.INACTIVE_TRAP ); + ROOM_RIGHT - ROOM_LEFT + 1, 1, Terrain.EMPTY_DECO ); arenaDoor = Random.Int( ROOM_LEFT, ROOM_RIGHT ) + (ROOM_BOTTOM + 1) * WIDTH; map[arenaDoor] = Terrain.DOOR; @@ -147,6 +143,15 @@ public class CavesBossLevel extends Level { map[i] = Terrain.WATER; } } + + for (int i=0; i < LENGTH; i++) { + if (map[i] == Terrain.EMPTY && Random.Int( 6 ) == 0) { + map[i] = Terrain.INACTIVE_TRAP; + Trap t = new ToxicTrap().reveal(); + t.active = false; + setTrap(t, i); + } + } return true; } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index f54d9942d..1002d6df5 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -344,6 +344,18 @@ public abstract class Level implements Bundlable { } traps.put( trap.pos, trap ); } + + //for pre-0.3.1 saves + if (version < 52){ + for (int i=0; i < map.length; i++){ + if (map[i] == Terrain.INACTIVE_TRAP){ + Trap t = new WornTrap().reveal(); + t.active = false; + t.pos = i; + traps.put( i, t); + } + } + } collection = bundle.getCollection( MOBS ); for (Bundlable m : collection) { @@ -638,7 +650,7 @@ public abstract class Level implements Bundlable { public static void set( int cell, int terrain ) { Painter.set( Dungeon.level, cell, terrain ); - if (terrain != Terrain.TRAP && terrain != Terrain.SECRET_TRAP){ + if (terrain != Terrain.TRAP && terrain != Terrain.SECRET_TRAP && terrain != Terrain.INACTIVE_TRAP){ Dungeon.level.traps.remove( cell ); } @@ -667,7 +679,7 @@ public abstract class Level implements Bundlable { //effectively nullifies whatever the logic calling this wants to do, including dropping items. Heap heap = new Heap(); ItemSprite sprite = heap.sprite = new ItemSprite(); - sprite.link( heap ); + sprite.link(heap); return heap; } @@ -707,7 +719,7 @@ public abstract class Level implements Bundlable { return drop( item, n ); } - heap.drop( item ); + heap.drop(item); if (Dungeon.level != null) { press( cell, null ); @@ -741,10 +753,15 @@ public abstract class Level implements Bundlable { } public void uproot( int pos ) { - plants.delete( pos ); + plants.delete(pos); } public Trap setTrap( Trap trap, int pos ){ + Trap existingTrap = traps.get(pos); + if (existingTrap != null){ + traps.delete( pos ); + if(existingTrap.sprite != null) existingTrap.sprite.kill(); + } trap.set( pos ); traps.put( pos, trap ); GameScene.add(trap); @@ -752,7 +769,6 @@ public abstract class Level implements Bundlable { } public void disarmTrap( int pos ) { - traps.delete(pos); set(pos, Terrain.INACTIVE_TRAP); GameScene.updateMap(pos); } diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java index 8910f8ebd..8f906b860 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonBossLevel.java @@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey; import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonTrap; +import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.watabou.noosa.Scene; import com.watabou.utils.Bundle; @@ -271,6 +272,14 @@ public class PrisonBossLevel extends RegularLevel { roomExit.width() - 3, roomExit.height() - 3, Terrain.INACTIVE_TRAP ); + + for (int cell : roomExit.getCells()){ + if (map[cell] == Terrain.INACTIVE_TRAP){ + Trap t = new PoisonTrap().reveal(); + t.active = false; + setTrap(t, cell); + } + } } @Override diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/Trap.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/Trap.java index 394026d0f..59ebf6f8b 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/Trap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/traps/Trap.java @@ -42,6 +42,7 @@ public abstract class Trap implements Bundlable { public TrapSprite sprite; public boolean visible; + public boolean active = true; public Trap set(int pos){ this.pos = pos; @@ -66,33 +67,41 @@ public abstract class Trap implements Bundlable { } public void trigger() { - if (Dungeon.visible[pos]){ - Sample.INSTANCE.play(Assets.SND_TRAP); + if (active) { + if (Dungeon.visible[pos]) { + Sample.INSTANCE.play(Assets.SND_TRAP); + } + disarm(); + activate(); } - disarm(); - activate(); } public abstract void activate(); protected void disarm(){ Dungeon.level.disarmTrap(pos); - if (sprite != null) sprite.kill(); + active = false; + if (sprite != null) sprite.reset( this ); } private static final String POS = "pos"; private static final String VISIBLE = "visible"; + private static final String ACTIVE = "active"; @Override public void restoreFromBundle( Bundle bundle ) { pos = bundle.getInt( POS ); visible = bundle.getBoolean( VISIBLE ); + if (bundle.contains(ACTIVE)){ + active = bundle.getBoolean(ACTIVE); + } } @Override public void storeInBundle( Bundle bundle ) { bundle.put( POS, pos ); bundle.put( VISIBLE, visible ); + bundle.put( ACTIVE, active ); } public String desc() { diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TrapSprite.java b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TrapSprite.java index cba0b2693..3c0b657e8 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TrapSprite.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/sprites/TrapSprite.java @@ -74,7 +74,7 @@ public class TrapSprite extends Image { revive(); - reset( trap.color + (trap.shape * 16) ); + reset( (trap.active ? trap.color : BLACK) + (trap.shape * 16) ); alpha( 1f ); pos = trap.pos; diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoTrap.java b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoTrap.java index 7fa786837..1591aa73e 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoTrap.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/windows/WndInfoTrap.java @@ -28,7 +28,9 @@ public class WndInfoTrap extends WndTitledMessage { public WndInfoTrap(Trap trap) { - super(new TrapSprite( trap.color + (trap.shape * 16) ), trap.name, trap.desc()); + super(new TrapSprite( trap.color + (trap.shape * 16) ), + (!trap.active ? "Inactive " : "") + trap.name, + (!trap.active ? "This trap is inactive, and can no longer be triggered.\n\n" : "") + trap.desc()); }