From 39b6c80e4af8bd98eaf00c9ef5d6ac798f6b3df7 Mon Sep 17 00:00:00 2001 From: Rapandrasmus <78219215+Rapandrasmus@users.noreply.github.com> Date: Mon, 7 Aug 2023 21:59:32 +0200 Subject: [PATCH] disappear fix --- .../Scripts/Games/MonkeyWatch/WatchMonkey.cs | 29 ++++++++++++------- .../Games/MonkeyWatch/WatchMonkeyHandler.cs | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs index c13fce380..fa4d863fd 100644 --- a/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkey.cs @@ -18,6 +18,9 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch private int direction = 0; public double monkeyBeat; + private double disappearBeat = 0; + private bool disappear = false; + private PlayerActionEvent inputEvent; private void Awake() @@ -38,6 +41,18 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch game.ScoreMiss(); } } + + if (disappear) + { + float normalizedBeat = Conductor.instance.GetPositionFromBeat(disappearBeat, 0.5f); + anim.DoNormalizedAnimation(isPink ? "PinkAppear" : "Appear", 1 - normalizedBeat); + float normalizedBeatClose = Conductor.instance.GetPositionFromBeat(disappearBeat + 0.25f, 0.25f); + holeAnim.DoNormalizedAnimation("HoleClose", Mathf.Clamp01(normalizedBeatClose)); + if (normalizedBeat > 1f) + { + Destroy(gameObject); + } + } } public void Appear(double beat, bool instant, Animator hole, int dir) @@ -49,17 +64,11 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch anim.DoScaledAnimationAsync(isPink ? "PinkAppear" : "Appear", 0.4f, instant ? 1 : 0); } - public void Disappear() + public void Disappear(double beat) { - holeAnim.DoScaledAnimationAsync("HoleClose", 0.4f); - anim.DoScaledAnimationAsync(isPink ? "PinkAppear" : "Appear", -0.4f, 1); - StartCoroutine(DisappearCoroutine()); - } - - private IEnumerator DisappearCoroutine() - { - yield return !anim.IsAnimationNotPlaying(); - Destroy(gameObject); + disappear = true; + disappearBeat = beat; + Update(); } public void Prepare(double prepareBeat, double inputBeat) diff --git a/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs index b417f9341..2dc156fea 100644 --- a/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs +++ b/Assets/Scripts/Games/MonkeyWatch/WatchMonkeyHandler.cs @@ -66,7 +66,7 @@ namespace HeavenStudio.Games.Scripts_MonkeyWatch currentMonkeys.Add(spawnedMonkey); if (currentMonkeys.Count > maxMonkeys) { - currentMonkeys[0].Disappear(); + currentMonkeys[0].Disappear(Conductor.instance.songPositionInBeats); currentMonkeys.Remove(currentMonkeys[0]); } }