update UI lose

This commit is contained in:
2026-06-06 02:51:35 +07:00
parent 3b24075a71
commit 75b005c691
2 changed files with 23 additions and 0 deletions

View File

@@ -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;

View File

@@ -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<FinishGate>();
if (gate != null)
{
gate.LoseGame();
}
}
public virtual void UpdateHUD(vThirdPersonController cc)