This commit is contained in:
2026-06-02 23:14:19 +07:00
parent b381bcef32
commit 1f9c10878a
166 changed files with 161639 additions and 12 deletions

View File

@@ -0,0 +1,59 @@
using UnityEngine;
using UnityEngine.UI; // Nếu dùng UI thường
using UnityEngine.SceneManagement;
public class FinishGate : MonoBehaviour
{
[Header("Cài đặt UI")]
public GameObject winPanel; // Kéo Panel hoặc Text "You Win" vào đây
private void Start()
{
Time.timeScale = 1;
if (winPanel != null) winPanel.SetActive(false); // Ẩn chữ Win lúc đầu game
}
private void OnTriggerEnter(Collider other)
{
PlayerInventory player = other.GetComponentInParent<PlayerInventory>();
if (player != null && player.hasTreasure)
{
WinGame();
}
}
void WinGame()
{
if (winPanel != null) winPanel.SetActive(true);
// Dừng game
Time.timeScale = 0f;
// Hiện chuột để bấm nút
Cursor.lockState = CursorLockMode.None;
Cursor.visible = true;
}
// --- HÀM CHO CÁC NÚT BẤM ---
public void RestartGame()
{
// Đặt lại thời gian về 1 trước khi load lại nếu không game sẽ bị đứng
Time.timeScale = 1f;
// Tải lại Scene hiện tại
SceneManager.LoadScene("Only AI");
Debug.Log("đang tải lại màn chơi : Only AI");
}
public void QuitGame()
{
Debug.Log("Đang thoát game...");
Application.Quit(); // Thoát file .exe (không có tác dụng trong trình dựng Unity)
#if UNITY_EDITOR
UnityEditor.EditorApplication.isPlaying = false; // Dừng chạy nếu đang ở trong Editor
#endif
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b97ebb3ed2a03534cbba257defc374a6

View File

@@ -0,0 +1,7 @@
using UnityEngine;
public class PlayerInventory : MonoBehaviour
{
// Biến kiểm tra xem người chơi đã nhặt kho báu chưa
public bool hasTreasure = false;
public int score = 0; // Điểm số nếu bạn muốn cộng thêm
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 16509f68a17b8004096bcf4acce328d6

View File

@@ -0,0 +1,18 @@
using UnityEngine;
public class TreasureItem : MonoBehaviour
{
private void OnTriggerEnter(Collider other)
{
// Kiểm tra xem thứ chạm vào có script PlayerInventory không
PlayerInventory player = other.GetComponentInParent<PlayerInventory>();
if (player != null && !player.hasTreasure)
{
player.hasTreasure = true;
Debug.Log("Đã nhặt kho báu!");
// Làm vật phẩm biến mất
gameObject.SetActive(false); // Hoặc Destroy(gameObject);
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 0bb610721d69d41438dc6d3a2b000705