Update
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
using Hallucinate.Audio; // Import namespace for AudioManager
|
||||
|
||||
public class FinishGate : MonoBehaviour
|
||||
{
|
||||
@@ -18,6 +19,11 @@ public class FinishGate : MonoBehaviour
|
||||
public GameObject winStar2;
|
||||
public GameObject winStar3;
|
||||
|
||||
[Header("Cài đặt Âm thanh")]
|
||||
public string winSound = "UI_Win";
|
||||
public string warningSound = "UI_Warning";
|
||||
public string clickSound = "UI_Click";
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Time.timeScale = 1f;
|
||||
@@ -76,6 +82,8 @@ public class FinishGate : MonoBehaviour
|
||||
winPanel.SetActive(true);
|
||||
UpdateWinStarsUI(count); // Hiện số sao tương ứng trên bảng kết thúc
|
||||
}
|
||||
|
||||
AudioManager.PlayGlobal(winSound); // Chạy âm thanh thắng cuộc
|
||||
|
||||
Time.timeScale = 0f;
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
@@ -86,18 +94,23 @@ public class FinishGate : MonoBehaviour
|
||||
{
|
||||
if (ui == null) yield break;
|
||||
ui.SetActive(true);
|
||||
|
||||
if (ui == warningUI) AudioManager.PlayGlobal(warningSound); // Chạy âm thanh cảnh báo
|
||||
|
||||
yield return new WaitForSeconds(3f);
|
||||
ui.SetActive(false);
|
||||
}
|
||||
|
||||
public void RestartGame()
|
||||
{
|
||||
AudioManager.PlayGlobal(clickSound); // Âm thanh click nút
|
||||
Time.timeScale = 1f;
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
AudioManager.PlayGlobal(clickSound); // Âm thanh click nút
|
||||
Application.Quit();
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.EditorApplication.isPlaying = false;
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using Hallucinate.Audio;
|
||||
|
||||
public class TreasureItem : MonoBehaviour
|
||||
{
|
||||
[Header("Cài đặt UI thông báo")]
|
||||
public GameObject notificationText; // Text "Đã nhặt Cổ vật"
|
||||
|
||||
[Header("Cài đặt Âm thanh")]
|
||||
public string pickupSound = "Item_Pickup";
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.CompareTag("Player"))
|
||||
@@ -29,6 +33,12 @@ public class TreasureItem : MonoBehaviour
|
||||
// 3. Kích hoạt trạng thái truy đuổi cho toàn bộ Enemy AI
|
||||
SetEnemiesAlertState(true);
|
||||
|
||||
// 4. Chạy âm thanh nhặt đồ
|
||||
if (AudioManager.Instance != null)
|
||||
{
|
||||
AudioManager.Instance.Play(pickupSound, position: transform.position);
|
||||
}
|
||||
|
||||
if (notificationText != null)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
|
||||
Reference in New Issue
Block a user