v0.8.0a: fixed various errors caused by new imp shop

This commit is contained in:
Evan Debenham 2020-04-23 17:32:31 -04:00
parent de448a0993
commit 0390b3dbad
2 changed files with 23 additions and 5 deletions

View File

@ -102,7 +102,9 @@ public class NewCityBossLevel extends Level {
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
impShop = (ImpShopRoom) bundle.get( IMP_SHOP );
if (map[topDoor] != Terrain.LOCKED_DOOR) impShop.onLevelLoad(this);
if (map[topDoor] != Terrain.LOCKED_DOOR && Imp.Quest.isCompleted() && !impShop.shopSpawned()){
spawnShop();
}
}
@Override
@ -157,9 +159,6 @@ public class NewCityBossLevel extends Level {
impShop = new ImpShopRoom();
impShop.set(end.left+3, end.top+12, end.left+11, end.top+20);
if (impShop.itemCount() > (7*7)){
impShop.bottom += 2;
}
Painter.set(this, impShop.center(), Terrain.PEDESTAL);
Painter.set(this, impShop.left+2, impShop.top, Terrain.STATUE);
@ -307,11 +306,18 @@ public class NewCityBossLevel extends Level {
GameScene.updateMap( topDoor );
if (Imp.Quest.isCompleted()) {
impShop.spawnShop(this);
spawnShop();
}
Dungeon.observe();
}
private void spawnShop(){
while (impShop.itemCount() >= 7*(impShop.height()-2)){
impShop.bottom++;
}
impShop.spawnShop(this);
}
@Override
public String tileName( int tile ) {
switch (tile) {

View File

@ -31,6 +31,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.ShopRoom;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.watabou.utils.Bundle;
import com.watabou.utils.Point;
//shops probably shouldn't extend special room, because of cases like this.
public class ImpShopRoom extends ShopRoom {
@ -76,6 +77,13 @@ public class ImpShopRoom extends ShopRoom {
int pos = level.pointToCell(center());
for (Point p : getPoints()){
if (level.map[level.pointToCell(p)] == Terrain.PEDESTAL){
pos = level.pointToCell(p);
break;
}
}
Mob shopkeeper = new ImpShopkeeper();
shopkeeper.pos = pos;
if (ShatteredPixelDungeon.scene() instanceof GameScene) {
@ -98,6 +106,10 @@ public class ImpShopRoom extends ShopRoom {
placeItems(level);
}
public boolean shopSpawned(){
return impSpawned;
}
private static final String IMP = "imp_spawned";
@Override