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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
||||
}
|
||||
|
||||
|
|