From 85b5937db82b710d87118ac720c42cfd98f09d96 Mon Sep 17 00:00:00 2001 From: Daffa Romyz Aufa <80190953+DaffaRomyz@users.noreply.github.com> Date: Sun, 16 Apr 2023 07:45:25 +0700 Subject: [PATCH] feat : load gameover scene if died --- Assets/Scripts/Managers/GameOverManager.cs | 49 +++++++++++----------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/Assets/Scripts/Managers/GameOverManager.cs b/Assets/Scripts/Managers/GameOverManager.cs index a1786ef2..92e70281 100755 --- a/Assets/Scripts/Managers/GameOverManager.cs +++ b/Assets/Scripts/Managers/GameOverManager.cs @@ -4,28 +4,29 @@ using UnityEngine.SceneManagement; public class GameOverManager : MonoBehaviour { -Â Â Â public Text warningText; -Â Â Â public PlayerHealth playerHealth; -Â -Â Â Â Animator anim; -Â -Â Â Â void Awake() -Â Â Â { -Â Â Â Â Â Â Â anim = GetComponent<Animator>(); -Â Â Â } -Â -Â Â Â void Update() -Â Â Â { -Â Â Â Â Â Â Â if (playerHealth.currentHealth <= 0) -Â Â Â Â Â Â Â { -Â Â Â Â Â Â Â Â Â Â Â anim.SetTrigger("GameOver"); -Â Â Â Â Â Â Â } -Â Â Â } -Â -Â Â Â public void ShowWarning(float enemyDistance) -Â Â Â { -Â Â Â Debug.Log("SHOWWARNING"); -Â Â Â Â Â Â Â warningText.text = string.Format("! {0} m",Mathf.RoundToInt(enemyDistance)); -Â Â Â Â Â Â Â anim.SetTrigger("Warning"); -Â Â Â } + public Text warningText; + public PlayerHealth playerHealth; + + Animator anim; + + void Awake() + { + anim = GetComponent<Animator>(); + } + + void Update() + { + if (playerHealth.currentHealth <= 0) + { +Â Â Â Â Â Â Â Â Â Â Â //anim.SetTrigger("GameOver"); + SceneManager.LoadScene("GameOverScene"); + } + } + + public void ShowWarning(float enemyDistance) + { + Debug.Log("SHOWWARNING"); + warningText.text = string.Format("! {0} m", Mathf.RoundToInt(enemyDistance)); + anim.SetTrigger("Warning"); + } } -- GitLab