v0.3.2: items lost to level 10 layout changes are now returned
This commit is contained in:
parent
a68f3b3c4c
commit
31c53c33d5
|
@ -37,6 +37,7 @@ import com.shatteredpixel.shatteredpixeldungeon.ui.CustomTileVisual;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.ui.HealthIndicator;
|
import com.shatteredpixel.shatteredpixeldungeon.ui.HealthIndicator;
|
||||||
import com.watabou.noosa.Scene;
|
import com.watabou.noosa.Scene;
|
||||||
import com.watabou.noosa.audio.Sample;
|
import com.watabou.noosa.audio.Sample;
|
||||||
|
import com.watabou.utils.Bundlable;
|
||||||
import com.watabou.utils.Bundle;
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.Random;
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
@ -60,6 +61,9 @@ public class PrisonBossLevel extends Level {
|
||||||
private State state;
|
private State state;
|
||||||
private Tengu tengu;
|
private Tengu tengu;
|
||||||
|
|
||||||
|
//keep track of that need to be removed as the level is changed. We dump 'em back into the level at the end.
|
||||||
|
private ArrayList<Item> storedItems = new ArrayList<>();
|
||||||
|
|
||||||
//we keep track of torches so we can kill them as needed when layouts change.
|
//we keep track of torches so we can kill them as needed when layouts change.
|
||||||
private ArrayList<PrisonLevel.Torch> torches = new ArrayList<>();
|
private ArrayList<PrisonLevel.Torch> torches = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -73,14 +77,16 @@ public class PrisonBossLevel extends Level {
|
||||||
return Assets.WATER_PRISON;
|
return Assets.WATER_PRISON;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String STATE = "state";
|
private static final String STATE = "state";
|
||||||
private static final String TENGU = "tengu";
|
private static final String TENGU = "tengu";
|
||||||
|
private static final String STORED_ITEMS = "storeditems";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void storeInBundle( Bundle bundle ) {
|
public void storeInBundle( Bundle bundle ) {
|
||||||
super.storeInBundle(bundle);
|
super.storeInBundle(bundle);
|
||||||
bundle.put( STATE, state );
|
bundle.put(STATE, state);
|
||||||
bundle.put( TENGU, tengu );
|
bundle.put( TENGU, tengu );
|
||||||
|
bundle.put( STORED_ITEMS, storedItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,6 +105,10 @@ public class PrisonBossLevel extends Level {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Bundlable item : bundle.getCollection(STORED_ITEMS)){
|
||||||
|
storedItems.add( (Item)item );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -135,16 +145,20 @@ public class PrisonBossLevel extends Level {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createItems() {
|
protected void createItems() {
|
||||||
int keyPos = 1+8*32; //initial position at top-left room
|
drop(new IronKey(10), randomPrisonCell());
|
||||||
|
}
|
||||||
|
|
||||||
|
private int randomPrisonCell(){
|
||||||
|
int pos = 1+8*32; //initial position at top-left room
|
||||||
|
|
||||||
//randomly assign a room.
|
//randomly assign a room.
|
||||||
keyPos += Random.Int(4)*(4*32); //one of the 4 rows
|
pos += Random.Int(4)*(4*32); //one of the 4 rows
|
||||||
keyPos += Random.Int(2)*6; // one of the 2 columns
|
pos += Random.Int(2)*6; // one of the 2 columns
|
||||||
|
|
||||||
//and then a certain tile in that room.
|
//and then a certain tile in that room.
|
||||||
keyPos += Random.Int(3) + Random.Int(3)*32;
|
pos += Random.Int(3) + Random.Int(3)*32;
|
||||||
|
|
||||||
drop(new IronKey(10), keyPos);
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -231,13 +245,19 @@ public class PrisonBossLevel extends Level {
|
||||||
addVisuals(ShatteredPixelDungeon.scene());
|
addVisuals(ShatteredPixelDungeon.scene());
|
||||||
resetTraps();
|
resetTraps();
|
||||||
|
|
||||||
for (Heap h : heaps.values().toArray(new Heap[heaps.values().size()])){
|
|
||||||
h.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
Dungeon.observe();
|
Dungeon.observe();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void clearHeaps(Room safeArea){
|
||||||
|
for (Heap heap : heaps.values()){
|
||||||
|
if (safeArea == null || !safeArea.inside(heap.pos)){
|
||||||
|
for (Item item : heap.items)
|
||||||
|
storedItems.add(item);
|
||||||
|
heap.destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void progress(){
|
public void progress(){
|
||||||
switch (state){
|
switch (state){
|
||||||
//moving to the beginning of the fight
|
//moving to the beginning of the fight
|
||||||
|
@ -258,6 +278,7 @@ public class PrisonBossLevel extends Level {
|
||||||
case FIGHT_START:
|
case FIGHT_START:
|
||||||
|
|
||||||
changeMap(MAP_MAZE);
|
changeMap(MAP_MAZE);
|
||||||
|
clearHeaps((Room)new Room().set(0, 5, 8, 32)); //clear all but the entrance
|
||||||
|
|
||||||
Actor.remove(tengu);
|
Actor.remove(tengu);
|
||||||
mobs.remove(tengu);
|
mobs.remove(tengu);
|
||||||
|
@ -278,6 +299,7 @@ public class PrisonBossLevel extends Level {
|
||||||
Dungeon.hero.sprite.place(Dungeon.hero.pos);
|
Dungeon.hero.sprite.place(Dungeon.hero.pos);
|
||||||
|
|
||||||
changeMap(MAP_ARENA);
|
changeMap(MAP_ARENA);
|
||||||
|
clearHeaps(null);
|
||||||
|
|
||||||
tengu.state = tengu.HUNTING;
|
tengu.state = tengu.HUNTING;
|
||||||
do {
|
do {
|
||||||
|
@ -307,9 +329,13 @@ public class PrisonBossLevel extends Level {
|
||||||
tengu.sprite.place(5 + 28 * 32);
|
tengu.sprite.place(5 + 28 * 32);
|
||||||
|
|
||||||
changeMap(MAP_END);
|
changeMap(MAP_END);
|
||||||
|
clearHeaps(null);
|
||||||
|
|
||||||
tengu.die(Dungeon.hero);
|
tengu.die(Dungeon.hero);
|
||||||
|
|
||||||
|
for (Item item : storedItems)
|
||||||
|
drop(item, randomPrisonCell());
|
||||||
|
|
||||||
state = State.WON;
|
state = State.WON;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user