diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index 127b7b1f0..03619bfe3 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -70,13 +70,11 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mimic; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Monk; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Snake; -import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.CheckedCell; import com.shatteredpixel.shatteredpixeldungeon.effects.Speck; import com.shatteredpixel.shatteredpixeldungeon.effects.SpellSprite; import com.shatteredpixel.shatteredpixeldungeon.effects.Splash; -import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; import com.shatteredpixel.shatteredpixeldungeon.items.Ankh; import com.shatteredpixel.shatteredpixeldungeon.items.Dewdrop; import com.shatteredpixel.shatteredpixeldungeon.items.EquipableItem; @@ -146,24 +144,16 @@ import com.shatteredpixel.shatteredpixeldungeon.mechanics.ShadowCaster; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.AlchemyScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; -import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene; -import com.shatteredpixel.shatteredpixeldungeon.scenes.SurfaceScene; -import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; -import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.ui.AttackIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton; import com.shatteredpixel.shatteredpixeldungeon.ui.StatusPane; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndHero; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.shatteredpixel.shatteredpixeldungeon.windows.WndResurrect; -import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage; import com.shatteredpixel.shatteredpixeldungeon.windows.WndTradeItem; import com.watabou.noosa.Game; import com.watabou.noosa.audio.Sample; @@ -1264,155 +1254,12 @@ public class Hero extends Char { ready(); return false; - //TODO, these checks are getting cumbersome, perhaps move them into Level? } else if (!Dungeon.level.locked && transition != null && transition.inside(pos)) { - if (transition.type == LevelTransition.Type.SURFACE){ - if (belongings.getItem( Amulet.class ) == null) { - Game.runOnRenderThread(new Callback() { - @Override - public void call() { - GameScene.show( new WndMessage( Messages.get(Hero.this, "leave") ) ); - } - }); - ready(); - } else { - Statistics.ascended = true; - Badges.silentValidateHappyEnd(); - Dungeon.win( Amulet.class ); - Dungeon.deleteGame( GamesInProgress.curSlot, true ); - Game.switchScene( SurfaceScene.class ); - } - - } else if (transition.type == LevelTransition.Type.REGULAR_ENTRANCE - && Dungeon.depth == 25 - //ascension challenge only works on runs started on v1.3+ - && Dungeon.initialVersion > ShatteredPixelDungeon.v1_2_3 - && belongings.getItem(Amulet.class) != null - && buff(AscensionChallenge.class) == null) { - - Game.runOnRenderThread(new Callback() { - @Override - public void call() { - GameScene.show( new WndOptions( new ItemSprite(ItemSpriteSheet.AMULET), - Messages.get(Amulet.class, "ascent_title"), - Messages.get(Amulet.class, "ascent_desc"), - Messages.get(Amulet.class, "ascent_yes"), - Messages.get(Amulet.class, "ascent_no")){ - @Override - protected void onSelect(int index) { - if (index == 0){ - Buff.affect(Hero.this, AscensionChallenge.class); - Statistics.highestAscent = 25; - actTransition(action); - } - } - } ); - } - }); - ready(); - - } else if (transition.type == LevelTransition.Type.BRANCH_EXIT - && Dungeon.depth >= 11 && Dungeon.depth <= 14 - && (!Blacksmith.Quest.given() || Blacksmith.Quest.oldQuestMineBlocked() || Blacksmith.Quest.completed() || !Blacksmith.Quest.started())) { - - if (Blacksmith.Quest.oldQuestMineBlocked()){ - GLog.w(Messages.get(Blacksmith.class, "cant_enter_old")); - } else if (!Blacksmith.Quest.given() || Blacksmith.Quest.completed()) { - GLog.w(Messages.get(Blacksmith.class, "entrance_blocked")); - } else if (!Blacksmith.Quest.started() && Blacksmith.Quest.Type() != 0){ - final Pickaxe pick = belongings.getItem(Pickaxe.class); - Game.runOnRenderThread(new Callback() { - @Override - public void call() { - if (pick == null){ - GameScene.show( new WndTitledMessage(new BlacksmithSprite(), - Messages.titleCase(Messages.get(Blacksmith.class, "name")), - Messages.get(Blacksmith.class, "lost_pick")) - ); - } else { - GameScene.show( new WndOptions( new BlacksmithSprite(), - Messages.titleCase(Messages.get(Blacksmith.class, "name")), - Messages.get(Blacksmith.class, "quest_start_prompt"), - Messages.get(Blacksmith.class, "enter_yes"), - Messages.get(Blacksmith.class, "enter_no")){ - @Override - protected void onSelect(int index) { - if (index == 0){ - Blacksmith.Quest.start(); - actTransition(action); - } - } - } ); - } - - } - }); - } - ready(); - - } else if (transition.type == LevelTransition.Type.BRANCH_ENTRANCE - && Dungeon.depth >= 11 && Dungeon.depth <= 14 - && !Blacksmith.Quest.completed() && Blacksmith.Quest.Type() != 0) { - - String warnText; - DarkGold gold = belongings.getItem(DarkGold.class); - int goldAmount = gold == null ? 0 : gold.quantity(); - if (goldAmount < 10){ - warnText = Messages.get(Blacksmith.class, "exit_warn_none"); - } else if (goldAmount < 20){ - warnText = Messages.get(Blacksmith.class, "exit_warn_low"); - } else if (goldAmount < 30){ - warnText = Messages.get(Blacksmith.class, "exit_warn_med"); - } else if (goldAmount < 40){ - warnText = Messages.get(Blacksmith.class, "exit_warn_high"); - } else { - warnText = Messages.get(Blacksmith.class, "exit_warn_full"); - } - - if (!Blacksmith.Quest.bossBeaten()){ - switch (Blacksmith.Quest.Type()){ - case 1: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_crystal"); break; - case 2: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_fungi"); break; - case 3: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_gnoll"); break; - } - } - - String finalWarnText = warnText; - Game.runOnRenderThread(new Callback() { - @Override - public void call() { - GameScene.show( new WndOptions( new BlacksmithSprite(), - Messages.titleCase(Messages.get(Blacksmith.class, "name")), - finalWarnText, - Messages.get(Blacksmith.class, "exit_yes"), - Messages.get(Blacksmith.class, "exit_no")){ - @Override - protected void onSelect(int index) { - if (index == 0){ - Blacksmith.Quest.complete(); - actTransition(action); - } - } - } ); - } - }); - ready(); - - } else { - + if (Dungeon.level.activateTransition(this, transition)){ curAction = null; - - Level.beforeTransition(); - InterlevelScene.curTransition = transition; - if (transition.type == LevelTransition.Type.REGULAR_EXIT - || transition.type == LevelTransition.Type.BRANCH_EXIT) { - InterlevelScene.mode = InterlevelScene.Mode.DESCEND; - } else { - InterlevelScene.mode = InterlevelScene.Mode.ASCEND; - } - Game.switchScene(InterlevelScene.class); - + } else { + ready(); } return false; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java index cf7349c25..e7cded561 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/CavesLevel.java @@ -23,7 +23,12 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; +import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.CavesPainter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; @@ -42,12 +47,18 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.StormTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.SummoningTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WarpingTrap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTileSheet; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndTitledMessage; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.audio.Music; import com.watabou.noosa.particles.PixelParticle; +import com.watabou.utils.Callback; import com.watabou.utils.PointF; import com.watabou.utils.Random; @@ -95,6 +106,59 @@ public class CavesLevel extends RegularLevel { .setTraps(nTraps(), trapClasses(), trapChances()); } + @Override + public boolean activateTransition(Hero hero, LevelTransition transition) { + if (transition.type == LevelTransition.Type.BRANCH_EXIT + && (!Blacksmith.Quest.given() || Blacksmith.Quest.oldQuestMineBlocked() || Blacksmith.Quest.completed() || !Blacksmith.Quest.started())) { + + Blacksmith smith = null; + for (Char c : Actor.chars()){ + if (c instanceof Blacksmith){ + smith = (Blacksmith) c; + break; + } + } + + if (Blacksmith.Quest.oldQuestMineBlocked()){ + GLog.w(Messages.get(Blacksmith.class, "cant_enter_old")); + } else if (smith == null || !Blacksmith.Quest.given() || Blacksmith.Quest.completed()) { + GLog.w(Messages.get(Blacksmith.class, "entrance_blocked")); + } else if (!Blacksmith.Quest.started() && Blacksmith.Quest.Type() != 0){ + final Pickaxe pick = hero.belongings.getItem(Pickaxe.class); + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + if (pick == null){ + GameScene.show( new WndTitledMessage(new BlacksmithSprite(), + Messages.titleCase(Messages.get(Blacksmith.class, "name")), + Messages.get(Blacksmith.class, "lost_pick")) + ); + } else { + GameScene.show( new WndOptions( new BlacksmithSprite(), + Messages.titleCase(Messages.get(Blacksmith.class, "name")), + Messages.get(Blacksmith.class, "quest_start_prompt"), + Messages.get(Blacksmith.class, "enter_yes"), + Messages.get(Blacksmith.class, "enter_no")){ + @Override + protected void onSelect(int index) { + if (index == 0){ + Blacksmith.Quest.start(); + CavesLevel.super.activateTransition(hero, transition); + } + } + } ); + } + + } + }); + } + return false; + + } else { + return super.activateTransition(hero, transition); + } + } + @Override public String tilesTex() { return Assets.Environment.TILES_CAVES; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java index 4c19cdd82..1dcb21d79 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/HallsBossLevel.java @@ -24,22 +24,30 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Bones; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.ShatteredPixelDungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.AscensionChallenge; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.YogDzewa; import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter; import com.shatteredpixel.shatteredpixeldungeon.effects.Pushing; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle; +import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Tilemap; @@ -305,6 +313,40 @@ public class HallsBossLevel extends Level { } } + @Override + public boolean activateTransition(Hero hero, LevelTransition transition) { + if (transition.type == LevelTransition.Type.REGULAR_ENTRANCE + //ascension challenge only works on runs started on v1.3+ + && Dungeon.initialVersion > ShatteredPixelDungeon.v1_2_3 + && hero.belongings.getItem(Amulet.class) != null + && hero.buff(AscensionChallenge.class) == null) { + + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + GameScene.show( new WndOptions( new ItemSprite(ItemSpriteSheet.AMULET), + Messages.get(Amulet.class, "ascent_title"), + Messages.get(Amulet.class, "ascent_desc"), + Messages.get(Amulet.class, "ascent_yes"), + Messages.get(Amulet.class, "ascent_no")){ + @Override + protected void onSelect(int index) { + if (index == 0){ + Buff.affect(hero, AscensionChallenge.class); + Statistics.highestAscent = 25; + HallsBossLevel.super.activateTransition(hero, transition); + } + } + } ); + } + }); + return false; + + } else { + return super.activateTransition(hero, transition); + } + } + @Override public String tileName( int tile ) { switch (tile) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 97505f22f..4e88ee4f0 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -79,13 +79,14 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Plant; import com.shatteredpixel.shatteredpixeldungeon.plants.Swiftthistle; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap; -import com.watabou.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.audio.Sample; +import com.watabou.utils.BArray; import com.watabou.utils.Bundlable; import com.watabou.utils.Bundle; import com.watabou.utils.GameMath; @@ -537,6 +538,24 @@ public abstract class Level implements Bundlable { return null; } + //returns true if we immediately transition, false otherwise + public boolean activateTransition(Hero hero, LevelTransition transition){ + if (locked){ + return false; + } + + beforeTransition(); + InterlevelScene.curTransition = transition; + if (transition.type == LevelTransition.Type.REGULAR_EXIT + || transition.type == LevelTransition.Type.BRANCH_EXIT) { + InterlevelScene.mode = InterlevelScene.Mode.DESCEND; + } else { + InterlevelScene.mode = InterlevelScene.Mode.ASCEND; + } + Game.switchScene(InterlevelScene.class); + return true; + } + //some buff effects have special logic or are cancelled from the hero before transitioning levels public static void beforeTransition(){ diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java index d7e8fb8dc..b3bca23c9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java @@ -24,11 +24,15 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Bones; import com.shatteredpixel.shatteredpixeldungeon.actors.Actor; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith; import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; +import com.shatteredpixel.shatteredpixeldungeon.items.quest.DarkGold; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.Builder; import com.shatteredpixel.shatteredpixeldungeon.levels.builders.FigureEightBuilder; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.MiningLevelPainter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; @@ -39,10 +43,15 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineSecretRoo import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MineSmallRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.StandardRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; +import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.sprites.BlacksmithSprite; import com.shatteredpixel.shatteredpixeldungeon.tiles.CustomTilemap; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndOptions; +import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Image; import com.watabou.noosa.Tilemap; +import com.watabou.utils.Callback; import com.watabou.utils.Random; import java.util.ArrayList; @@ -150,6 +159,60 @@ public class MiningLevel extends CavesLevel { } } + @Override + public boolean activateTransition(Hero hero, LevelTransition transition) { + if (transition.type == LevelTransition.Type.BRANCH_ENTRANCE + && !Blacksmith.Quest.completed() && Blacksmith.Quest.Type() != 0) { + + String warnText; + DarkGold gold = hero.belongings.getItem(DarkGold.class); + int goldAmount = gold == null ? 0 : gold.quantity(); + if (goldAmount < 10){ + warnText = Messages.get(Blacksmith.class, "exit_warn_none"); + } else if (goldAmount < 20){ + warnText = Messages.get(Blacksmith.class, "exit_warn_low"); + } else if (goldAmount < 30){ + warnText = Messages.get(Blacksmith.class, "exit_warn_med"); + } else if (goldAmount < 40){ + warnText = Messages.get(Blacksmith.class, "exit_warn_high"); + } else { + warnText = Messages.get(Blacksmith.class, "exit_warn_full"); + } + + if (!Blacksmith.Quest.bossBeaten()){ + switch (Blacksmith.Quest.Type()){ + case 1: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_crystal"); break; + case 2: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_fungi"); break; + case 3: warnText += "\n\n" + Messages.get(Blacksmith.class, "exit_warn_gnoll"); break; + } + } + + String finalWarnText = warnText; + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + GameScene.show(new WndOptions( new BlacksmithSprite(), + Messages.titleCase(Messages.get(Blacksmith.class, "name")), + finalWarnText, + Messages.get(Blacksmith.class, "exit_yes"), + Messages.get(Blacksmith.class, "exit_no")){ + @Override + protected void onSelect(int index) { + if (index == 0){ + Blacksmith.Quest.complete(); + MiningLevel.super.activateTransition(hero, transition); + } + } + } ); + } + }); + return false; + + } else { + return super.activateTransition(hero, transition); + } + } + @Override public String tileDesc( int tile ) { switch (tile) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java index a8bb61b8b..b9dd88ffc 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java @@ -22,9 +22,15 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; +import com.shatteredpixel.shatteredpixeldungeon.Badges; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.GamesInProgress; +import com.shatteredpixel.shatteredpixeldungeon.Statistics; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Ghost; import com.shatteredpixel.shatteredpixeldungeon.effects.Ripple; +import com.shatteredpixel.shatteredpixeldungeon.items.Amulet; +import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.SewerPainter; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.AlarmTrap; @@ -41,12 +47,15 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.WornDartTrap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; +import com.shatteredpixel.shatteredpixeldungeon.scenes.SurfaceScene; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.shatteredpixel.shatteredpixeldungeon.windows.WndMessage; import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.audio.Music; import com.watabou.noosa.particles.Emitter; import com.watabou.noosa.particles.PixelParticle; +import com.watabou.utils.Callback; import com.watabou.utils.ColorMath; import com.watabou.utils.PointF; import com.watabou.utils.Random; @@ -123,6 +132,30 @@ public class SewerLevel extends RegularLevel { super.createMobs(); } + @Override + public boolean activateTransition(Hero hero, LevelTransition transition) { + if (transition.type == LevelTransition.Type.SURFACE){ + if (hero.belongings.getItem( Amulet.class ) == null) { + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + GameScene.show( new WndMessage( Messages.get(hero, "leave") ) ); + } + }); + return false; + } else { + Statistics.ascended = true; + Badges.silentValidateHappyEnd(); + Dungeon.win( Amulet.class ); + Dungeon.deleteGame( GamesInProgress.curSlot, true ); + Game.switchScene( SurfaceScene.class ); + return true; + } + } else { + return super.activateTransition(hero, transition); + } + } + @Override public Group addVisuals() { super.addVisuals();