diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java index bf76dfbc8..9a3baa5a5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Elemental.java @@ -52,8 +52,11 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite; import com.shatteredpixel.shatteredpixeldungeon.sprites.ElementalSprite; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.Game; +import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; +import com.watabou.utils.Callback; import com.watabou.utils.PathFinder; import com.watabou.utils.Random; @@ -381,6 +384,17 @@ public abstract class Elemental extends Mob { if (alignment == Alignment.ENEMY) { Dungeon.level.drop( new Embers(), pos ).sprite.drop(); Statistics.questScores[1] = 2000; + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + Music.INSTANCE.fadeOut(1f, new Callback() { + @Override + public void call() { + Dungeon.level.playLevelMusic(); + } + }); + } + }); } } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java index 750fb1054..125d408b6 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Ghost.java @@ -48,6 +48,7 @@ import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.windows.WndQuest; import com.shatteredpixel.shatteredpixeldungeon.windows.WndSadGhost; import com.watabou.noosa.Game; +import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; import com.watabou.utils.Callback; @@ -173,7 +174,18 @@ public class Ghost extends NPC { Game.runOnRenderThread(new Callback() { @Override public void call() { - GameScene.show( new WndQuest( Ghost.this, txt_quest ) ); + GameScene.show( new WndQuest( Ghost.this, txt_quest ){ + @Override + public void hide() { + super.hide(); + Music.INSTANCE.fadeOut(1f, new Callback() { + @Override + public void call() { + Dungeon.level.playLevelMusic(); + } + }); + } + } ); } }); } @@ -335,8 +347,24 @@ public class Ghost extends NPC { Sample.INSTANCE.play( Assets.Sounds.GHOST ); processed = true; Statistics.questScores[0] = 1000; + + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + Music.INSTANCE.fadeOut(1f, new Callback() { + @Override + public void call() { + Dungeon.level.playLevelMusic(); + } + }); + } + }); } } + + public static boolean active(){ + return given && !processed && depth == Dungeon.depth; + } public static void complete() { weapon = null; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java index 3c8939c51..6e46aeee9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/npcs/Wandmaker.java @@ -26,7 +26,11 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics; 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.mobs.Elemental; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob; +import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.RotHeart; import com.shatteredpixel.shatteredpixeldungeon.items.Generator; +import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.quest.CeremonialCandle; import com.shatteredpixel.shatteredpixeldungeon.items.quest.CorpseDust; @@ -34,10 +38,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.quest.Embers; import com.shatteredpixel.shatteredpixeldungeon.items.wands.Wand; import com.shatteredpixel.shatteredpixeldungeon.journal.Notes; import com.shatteredpixel.shatteredpixeldungeon.levels.Level; +import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.Room; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.MassGraveRoom; -import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.RotGardenRoom; import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.RitualSiteRoom; +import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.quest.RotGardenRoom; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.plants.Rotberry; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; @@ -349,6 +354,79 @@ public class Wandmaker extends NPC { } return rooms; } + + //quest is active if: + public static boolean active(){ + //it is not completed + if (wand1 == null || wand2 == null || !(Dungeon.level instanceof RegularLevel)){ + return false; + } + + //and... + if (type == 1){ + //hero is in the mass grave room + if (((RegularLevel) Dungeon.level).room(Dungeon.hero.pos) instanceof MassGraveRoom) { + return true; + } + + //or if they are corpse dust cursed + for (Buff b : Dungeon.hero.buffs()) { + if (b instanceof CorpseDust.DustGhostSpawner) { + return true; + } + } + + return false; + } else if (type == 2){ + //hero is in the ritual room and all 4 candles are with them + if (((RegularLevel) Dungeon.level).room(Dungeon.hero.pos) instanceof RitualSiteRoom) { + int candles = 0; + if (Dungeon.hero.belongings.getItem(CeremonialCandle.class) != null){ + candles += Dungeon.hero.belongings.getItem(CeremonialCandle.class).quantity(); + } + + if (candles >= 4){ + return true; + } + + for (Heap h : Dungeon.level.heaps.valueList()){ + if (((RegularLevel) Dungeon.level).room(h.pos) instanceof RitualSiteRoom){ + for (Item i : h.items){ + if (i instanceof CeremonialCandle){ + candles += i.quantity(); + } + } + } + } + + if (candles >= 4){ + return true; + } + + return false; + } + + //or they have summoned but not killed the newborn elemental + for (Mob m : Dungeon.level.mobs) { + if (m instanceof Elemental.NewbornFireElemental) { + return true; + } + } + + return false; + } else { + //hero is in the rot garden room and the rot heart is alive + if (((RegularLevel) Dungeon.level).room(Dungeon.hero.pos) instanceof RotGardenRoom) { + for (Mob m : Dungeon.level.mobs) { + if (m instanceof RotHeart) { + return true; + } + } + } + + return false; + } + } public static void complete() { wand1 = null; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/CorpseDust.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/CorpseDust.java index f1b658ce1..94a44c0c8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/CorpseDust.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/quest/CorpseDust.java @@ -32,8 +32,11 @@ import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; +import com.watabou.noosa.Game; +import com.watabou.noosa.audio.Music; import com.watabou.noosa.audio.Sample; import com.watabou.utils.Bundle; +import com.watabou.utils.Callback; import com.watabou.utils.Random; import java.util.ArrayList; @@ -141,6 +144,18 @@ public class CorpseDust extends Item { mob.die(null); } } + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + //maybe have a fade here? + Music.INSTANCE.fadeOut(1f, new Callback() { + @Override + public void call() { + Dungeon.level.playLevelMusic(); + } + }); + } + }); } private static String SPAWNPOWER = "spawnpower"; 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 b3bca23c9..cf90eb2c9 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/MiningLevel.java @@ -51,6 +51,7 @@ import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Image; import com.watabou.noosa.Tilemap; +import com.watabou.noosa.audio.Music; import com.watabou.utils.Callback; import com.watabou.utils.Random; @@ -59,6 +60,11 @@ import java.util.Arrays; public class MiningLevel extends CavesLevel { + @Override + public void playLevelMusic() { + Music.INSTANCE.play(Assets.Music.CAVES_TENSE, true); + } + @Override protected ArrayList initRooms() { ArrayList initRooms = new ArrayList<>(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java index e6878bbb3..ee4fdbd22 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/PrisonLevel.java @@ -24,6 +24,7 @@ package com.shatteredpixel.shatteredpixeldungeon.levels; import com.shatteredpixel.shatteredpixeldungeon.Assets; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; import com.shatteredpixel.shatteredpixeldungeon.Statistics; +import com.shatteredpixel.shatteredpixeldungeon.actors.Char; import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Wandmaker; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle; import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter; @@ -45,10 +46,12 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.traps.TeleportationTrap; import com.shatteredpixel.shatteredpixeldungeon.levels.traps.ToxicTrap; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap; +import com.watabou.noosa.Game; import com.watabou.noosa.Group; import com.watabou.noosa.Halo; import com.watabou.noosa.audio.Music; import com.watabou.noosa.particles.Emitter; +import com.watabou.utils.Callback; import com.watabou.utils.PointF; import com.watabou.utils.Random; @@ -63,7 +66,7 @@ public class PrisonLevel extends RegularLevel { @Override public void playLevelMusic() { - if (Statistics.amuletObtained){ + if (Wandmaker.Quest.active() || Statistics.amuletObtained){ Music.INSTANCE.play(Assets.Music.PRISON_TENSE, true); } else { Music.INSTANCE.playTracks( @@ -71,6 +74,7 @@ public class PrisonLevel extends RegularLevel { new float[]{1, 1, 0.5f}, false); } + wandmakerQuestWasActive = Wandmaker.Quest.active(); } @Override @@ -132,6 +136,34 @@ public class PrisonLevel extends RegularLevel { 1, 1, 1, 1, 1, 1 }; } + private Boolean wandmakerQuestWasActive = null; + + @Override + public void occupyCell(Char ch) { + super.occupyCell(ch); + if (ch == Dungeon.hero) { + if (wandmakerQuestWasActive == null) { + wandmakerQuestWasActive = Wandmaker.Quest.active(); + return; + } + if (Wandmaker.Quest.active() != wandmakerQuestWasActive) { + wandmakerQuestWasActive = Wandmaker.Quest.active(); + + Game.runOnRenderThread(new Callback() { + @Override + public void call() { + Music.INSTANCE.fadeOut(1f, new Callback() { + @Override + public void call() { + Dungeon.level.playLevelMusic(); + } + }); + } + }); + } + } + } + @Override public String tileName( 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 35c6f23ca..63ef02fa1 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/levels/SewerLevel.java @@ -67,7 +67,7 @@ public class SewerLevel extends RegularLevel { } public void playLevelMusic(){ - if (Statistics.amuletObtained){ + if (Ghost.Quest.active() || Statistics.amuletObtained){ Music.INSTANCE.play(Assets.Music.SEWERS_TENSE, true); } else { Music.INSTANCE.playTracks(