update AI

This commit is contained in:
2026-06-03 04:32:58 +07:00
parent 1f9c10878a
commit 644e3d7a96
118 changed files with 10800 additions and 48 deletions

View File

@@ -1,18 +1,41 @@
using UnityEngine;
using System.Collections;
public class TreasureItem : MonoBehaviour
{
[Header("Cài đặt UI thông báo")]
public GameObject notificationText;
private void Start()
{
if (notificationText != null) notificationText.SetActive(false);
}
private void OnTriggerEnter(Collider other)
{
// Kiểm tra xem thứ chạm vào có script PlayerInventory không
// Tìm PlayerInventory ở đối tượng hoặc cha của nó
PlayerInventory player = other.GetComponentInParent<PlayerInventory>();
if (player != null && !player.hasTreasure)
if (player != null)
{
player.hasTreasure = true;
Debug.Log("Đã nhặt kho báu!");
player.treasuresCollected += 1;
Debug.Log("Đã nhặt rương! Tổng cộng: " + player.treasuresCollected);
if (notificationText != null)
{
StopAllCoroutines();
StartCoroutine(ShowNotification());
}
// Làm vật phẩm biến mất
gameObject.SetActive(false); // Hoặc Destroy(gameObject);
// Biến mất rương
gameObject.SetActive(false);
}
}
IEnumerator ShowNotification()
{
notificationText.SetActive(true);
yield return new WaitForSeconds(2f);
notificationText.SetActive(false);
}
}