add project files
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user