From c027503426125a58cb01f5b056cef8a87c35e1c2 Mon Sep 17 00:00:00 2001 From: Malik Rafsanjani <pro.malikakbar2357@gmail.com> Date: Sun, 16 Apr 2023 14:28:32 +0700 Subject: [PATCH] fix: resolve bug on reset money --- Assets/Scripts/Managers/GameControl.cs | 5 +++++ Assets/Scripts/Player/PlayerHealth.cs | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Assets/Scripts/Managers/GameControl.cs b/Assets/Scripts/Managers/GameControl.cs index fd2622b..dfbe9d6 100644 --- a/Assets/Scripts/Managers/GameControl.cs +++ b/Assets/Scripts/Managers/GameControl.cs @@ -74,6 +74,11 @@ public class GameControl : MonoBehaviour currency -= amt; } + public void Reset() + { + currency = 0; + } + // From: https://johnleonardfrench.com/how-to-fade-audio-in-unity-i-tested-every-method-this-ones-the-best public IEnumerator StartFade(AudioSource audioSource, float duration, float targetVolume, GameObject theGameObject) { diff --git a/Assets/Scripts/Player/PlayerHealth.cs b/Assets/Scripts/Player/PlayerHealth.cs index 367a653..eb21ca8 100644 --- a/Assets/Scripts/Player/PlayerHealth.cs +++ b/Assets/Scripts/Player/PlayerHealth.cs @@ -48,6 +48,8 @@ public class PlayerHealth : MonoBehaviour currentHealth = startingHealth; } + // reset + GameControl.control.Reset(); healthSlider.value = currentHealth; } -- GitLab