24 lines
493 B
C#
24 lines
493 B
C#
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);
|
|
}
|
|
}
|
|
} |