v0.3.1: added in logic for the proper display of inactive traps
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.7 KiB After Width: | Height: | Size: 8.5 KiB |
Before Width: | Height: | Size: 8.4 KiB After Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
@ -20,6 +20,8 @@
|
||||||
*/
|
*/
|
||||||
package com.shatteredpixel.shatteredpixeldungeon.levels;
|
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.Camera;
|
||||||
import com.watabou.noosa.Scene;
|
import com.watabou.noosa.Scene;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
@ -120,19 +122,13 @@ public class CavesBossLevel extends Level {
|
||||||
|
|
||||||
map[exit] = Terrain.LOCKED_EXIT;
|
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,
|
Painter.fill( this, ROOM_LEFT - 1, ROOM_TOP - 1,
|
||||||
ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL );
|
ROOM_RIGHT - ROOM_LEFT + 3, ROOM_BOTTOM - ROOM_TOP + 3, Terrain.WALL );
|
||||||
Painter.fill( this, ROOM_LEFT, ROOM_TOP + 1,
|
Painter.fill( this, ROOM_LEFT, ROOM_TOP + 1,
|
||||||
ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP, Terrain.EMPTY );
|
ROOM_RIGHT - ROOM_LEFT + 1, ROOM_BOTTOM - ROOM_TOP, Terrain.EMPTY );
|
||||||
|
|
||||||
Painter.fill( this, ROOM_LEFT, ROOM_TOP,
|
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;
|
arenaDoor = Random.Int( ROOM_LEFT, ROOM_RIGHT ) + (ROOM_BOTTOM + 1) * WIDTH;
|
||||||
map[arenaDoor] = Terrain.DOOR;
|
map[arenaDoor] = Terrain.DOOR;
|
||||||
|
@ -148,6 +144,15 @@ public class CavesBossLevel extends Level {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -345,6 +345,18 @@ public abstract class Level implements Bundlable {
|
||||||
traps.put( trap.pos, trap );
|
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 );
|
collection = bundle.getCollection( MOBS );
|
||||||
for (Bundlable m : collection) {
|
for (Bundlable m : collection) {
|
||||||
Mob mob = (Mob)m;
|
Mob mob = (Mob)m;
|
||||||
|
@ -638,7 +650,7 @@ public abstract class Level implements Bundlable {
|
||||||
public static void set( int cell, int terrain ) {
|
public static void set( int cell, int terrain ) {
|
||||||
Painter.set( Dungeon.level, cell, 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 );
|
Dungeon.level.traps.remove( cell );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -745,6 +757,11 @@ public abstract class Level implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Trap setTrap( Trap trap, int 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 );
|
trap.set( pos );
|
||||||
traps.put( pos, trap );
|
traps.put( pos, trap );
|
||||||
GameScene.add(trap);
|
GameScene.add(trap);
|
||||||
|
@ -752,7 +769,6 @@ public abstract class Level implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disarmTrap( int pos ) {
|
public void disarmTrap( int pos ) {
|
||||||
traps.delete(pos);
|
|
||||||
set(pos, Terrain.INACTIVE_TRAP);
|
set(pos, Terrain.INACTIVE_TRAP);
|
||||||
GameScene.updateMap(pos);
|
GameScene.updateMap(pos);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import com.shatteredpixel.shatteredpixeldungeon.items.keys.SkeletonKey;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.Room.Type;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonTrap;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.PoisonTrap;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.levels.traps.Trap;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.watabou.noosa.Scene;
|
import com.watabou.noosa.Scene;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
|
@ -271,6 +272,14 @@ public class PrisonBossLevel extends RegularLevel {
|
||||||
roomExit.width() - 3,
|
roomExit.width() - 3,
|
||||||
roomExit.height() - 3,
|
roomExit.height() - 3,
|
||||||
Terrain.INACTIVE_TRAP );
|
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
|
@Override
|
||||||
|
|
|
@ -42,6 +42,7 @@ public abstract class Trap implements Bundlable {
|
||||||
|
|
||||||
public TrapSprite sprite;
|
public TrapSprite sprite;
|
||||||
public boolean visible;
|
public boolean visible;
|
||||||
|
public boolean active = true;
|
||||||
|
|
||||||
public Trap set(int pos){
|
public Trap set(int pos){
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
|
@ -66,33 +67,41 @@ public abstract class Trap implements Bundlable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void trigger() {
|
public void trigger() {
|
||||||
|
if (active) {
|
||||||
if (Dungeon.visible[pos]) {
|
if (Dungeon.visible[pos]) {
|
||||||
Sample.INSTANCE.play(Assets.SND_TRAP);
|
Sample.INSTANCE.play(Assets.SND_TRAP);
|
||||||
}
|
}
|
||||||
disarm();
|
disarm();
|
||||||
activate();
|
activate();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public abstract void activate();
|
public abstract void activate();
|
||||||
|
|
||||||
protected void disarm(){
|
protected void disarm(){
|
||||||
Dungeon.level.disarmTrap(pos);
|
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 POS = "pos";
|
||||||
private static final String VISIBLE = "visible";
|
private static final String VISIBLE = "visible";
|
||||||
|
private static final String ACTIVE = "active";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreFromBundle( Bundle bundle ) {
|
public void restoreFromBundle( Bundle bundle ) {
|
||||||
pos = bundle.getInt( POS );
|
pos = bundle.getInt( POS );
|
||||||
visible = bundle.getBoolean( VISIBLE );
|
visible = bundle.getBoolean( VISIBLE );
|
||||||
|
if (bundle.contains(ACTIVE)){
|
||||||
|
active = bundle.getBoolean(ACTIVE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle( Bundle bundle ) {
|
public void storeInBundle( Bundle bundle ) {
|
||||||
bundle.put( POS, pos );
|
bundle.put( POS, pos );
|
||||||
bundle.put( VISIBLE, visible );
|
bundle.put( VISIBLE, visible );
|
||||||
|
bundle.put( ACTIVE, active );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String desc() {
|
public String desc() {
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class TrapSprite extends Image {
|
||||||
|
|
||||||
revive();
|
revive();
|
||||||
|
|
||||||
reset( trap.color + (trap.shape * 16) );
|
reset( (trap.active ? trap.color : BLACK) + (trap.shape * 16) );
|
||||||
alpha( 1f );
|
alpha( 1f );
|
||||||
|
|
||||||
pos = trap.pos;
|
pos = trap.pos;
|
||||||
|
|
|
@ -28,7 +28,9 @@ public class WndInfoTrap extends WndTitledMessage {
|
||||||
|
|
||||||
public WndInfoTrap(Trap trap) {
|
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());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|