40 lines
800 B
C#
40 lines
800 B
C#
using System;
|
|
using UnityEngine;
|
|
using OHM.UnityToolkit;
|
|
using UnityEngine.Serialization;
|
|
|
|
public class PickUpItemHandler : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private SFX GoodItem;
|
|
|
|
[SerializeField]
|
|
private SFX BadItem;
|
|
|
|
[SerializeField]
|
|
[FormerlySerializedAs("keyItem")]
|
|
private SFX _keyItem;
|
|
|
|
public event Action<PickUpItem> onPickUpItem;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
PickUpItem item = other.GetComponentInParent<PickUpItem>();
|
|
if (item != null && !item.isUse)
|
|
{
|
|
item.UseItem();
|
|
SFX sfx = (((int)item.valueChange >= 1) ? GoodItem : BadItem);
|
|
sfx.Play(base.transform);
|
|
if (this.onPickUpItem != null)
|
|
{
|
|
this.onPickUpItem(item);
|
|
}
|
|
}
|
|
Doors doors = other.GetComponentInParent<Doors>();
|
|
if (doors != null)
|
|
{
|
|
doors.DisableDoors();
|
|
}
|
|
}
|
|
}
|