From 75b005c69169935b34745e13929b164042454e0d Mon Sep 17 00:00:00 2001 From: ngtuanz1 Date: Sat, 6 Jun 2026 02:51:35 +0700 Subject: [PATCH] update UI lose --- Assets/Scripts/Cho mon AI/FinishGate.cs | 16 ++++++++++++++++ .../Player/CharacterController/vHUDController.cs | 7 +++++++ 2 files changed, 23 insertions(+) diff --git a/Assets/Scripts/Cho mon AI/FinishGate.cs b/Assets/Scripts/Cho mon AI/FinishGate.cs index f1576569..0f50c7b9 100644 --- a/Assets/Scripts/Cho mon AI/FinishGate.cs +++ b/Assets/Scripts/Cho mon AI/FinishGate.cs @@ -7,6 +7,7 @@ public class FinishGate : MonoBehaviour { [Header("Cài đặt UI Chính")] public GameObject winPanel; + public GameObject losePanel; // Bảng Lose public GameObject welcomeUI; // THÔNG BÁO 1: "Chào mừng!" public GameObject warningUI; // THÔNG BÁO 2: "Bạn chưa nhặt rương nào!" @@ -22,6 +23,7 @@ public class FinishGate : MonoBehaviour [Header("Cài đặt Âm thanh")] public string winSound = "UI_Win"; + public string loseSound = "UI_Lose"; // Âm thanh thua public string warningSound = "UI_Warning"; public string clickSound = "UI_Click"; @@ -35,6 +37,7 @@ public class FinishGate : MonoBehaviour Time.timeScale = 1f; if (winPanel != null) winPanel.SetActive(false); + if (losePanel != null) losePanel.SetActive(false); if (welcomeUI != null) welcomeUI.SetActive(false); if (warningUI != null) warningUI.SetActive(false); @@ -101,6 +104,19 @@ public class FinishGate : MonoBehaviour Cursor.visible = true; } + public void LoseGame() + { + if (losePanel != null) + { + losePanel.SetActive(true); + } + + AudioManager.PlayGlobal(loseSound); + Time.timeScale = 0f; + Cursor.lockState = CursorLockMode.None; + Cursor.visible = true; + } + private IEnumerator ShowTempUI(GameObject ui) { if (ui == null) yield break; diff --git a/Assets/Scripts/Player/CharacterController/vHUDController.cs b/Assets/Scripts/Player/CharacterController/vHUDController.cs index b2c43e8a..8f87fa63 100644 --- a/Assets/Scripts/Player/CharacterController/vHUDController.cs +++ b/Assets/Scripts/Player/CharacterController/vHUDController.cs @@ -98,6 +98,13 @@ namespace Invector.vCharacterController private void OnDead(GameObject arg0) { ShowText("You are Dead!"); + + // Gọi hàm LoseGame từ script FinishGate khi người chơi chết + FinishGate gate = Object.FindAnyObjectByType(); + if (gate != null) + { + gate.LoseGame(); + } } public virtual void UpdateHUD(vThirdPersonController cc)