diff --git a/Assets/Scripts/Games/NailCarpenter/NailCarpenter.cs b/Assets/Scripts/Games/NailCarpenter/NailCarpenter.cs index 3fc45216a..ac88c99ee 100644 --- a/Assets/Scripts/Games/NailCarpenter/NailCarpenter.cs +++ b/Assets/Scripts/Games/NailCarpenter/NailCarpenter.cs @@ -16,21 +16,25 @@ namespace HeavenStudio.Games.Loaders { new GameAction("puddingNail", "Pudding Nail") { + function = delegate {NailCarpenter.instance.PlaySound();}, defaultLength = 4f, resizable = true }, new GameAction("cherryNail", "Cherry Nail") { + function = delegate {NailCarpenter.instance.PlaySound();}, defaultLength = 2f, resizable = true }, new GameAction("cakeNail", "Cake Nail") { + function = delegate {NailCarpenter.instance.PlaySound();}, defaultLength = 2f, resizable = true }, new GameAction("cakeLongNail", "Cake Long Nail") { + function = delegate {NailCarpenter.instance.PlaySound();}, defaultLength = 2f, resizable = true }, @@ -187,7 +191,6 @@ namespace HeavenStudio.Games List cakeNailEvents = entities.FindAll(v => v.datamodel == "nailCarpenter/cakeNail"); List cklNailEvents = entities.FindAll(v => v.datamodel == "nailCarpenter/cakeLongNail"); - var sounds = new List(){}; var cherryTargetBeats = new List(){}; // Spawn cake and nail. @@ -307,10 +310,6 @@ namespace HeavenStudio.Games } } } - - if (sounds.Count > 0) { - MultiSound.Play(sounds.ToArray(), forcePlay: true); - } } public override void OnPlay(double beat) @@ -388,5 +387,18 @@ namespace HeavenStudio.Games return false; } + // MultiSound.Play may not work in OnPlay (OnGameSwitch?), so I play the audio using an alternative method. + List sounds = new List(){}; + bool isPlayed = false; + public void PlaySound() + { + if (isPlayed) return; + if (sounds.Count > 0) { + MultiSound.Play(sounds.ToArray()); + isPlayed = true; + sounds = null; + } + } + } } \ No newline at end of file diff --git a/Assets/Scripts/Games/NailCarpenter/Sweet.cs b/Assets/Scripts/Games/NailCarpenter/Sweet.cs index 72150eeaa..596d8a0f4 100644 --- a/Assets/Scripts/Games/NailCarpenter/Sweet.cs +++ b/Assets/Scripts/Games/NailCarpenter/Sweet.cs @@ -36,7 +36,6 @@ namespace HeavenStudio.Games.Scripts_NailCarpenter } private void AwakeAnim() { - Debug.Log(sweetType); switch(sweetType) { case sweetsType.Pudding: