diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewCityBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewCityBossLevel.java index fa3f84351..ce193b8d4 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewCityBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/NewCityBossLevel.java @@ -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) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java index 34101c43a..8597eb88c 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/rooms/standard/ImpShopRoom.java @@ -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