添加教堂
This commit is contained in:
24
Assets/Scripts/Mono/CollectableItem.cs
Normal file
24
Assets/Scripts/Mono/CollectableItem.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class CollectableItem : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private string _collectorTag;
|
||||
|
||||
[SerializeField]
|
||||
private int _itemID;
|
||||
|
||||
public int ItemID => _itemID;
|
||||
|
||||
public event EventHandler OnCollected;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.gameObject.CompareTag(_collectorTag))
|
||||
{
|
||||
OnCollected?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user