51 lines
1.4 KiB
C#
51 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using InfallibleCode;
|
|
|
|
public class CollectibleEntryPickUp : MonoBehaviour
|
|
{
|
|
|
|
public ExaminableItem examinableItem;
|
|
|
|
[SerializeField] private string CollectibleEntryNameID;
|
|
|
|
[HideInInspector] public bool ItemCollected;
|
|
public MeshRenderer _EntryGameObject;
|
|
|
|
|
|
public EventDelegateTrigger eventDelegateTriggerOnEntryObtained;
|
|
|
|
void Start()
|
|
{
|
|
_EntryGameObject = GetComponent<MeshRenderer>();
|
|
examinableItem = GetComponent<ExaminableItem>();
|
|
}
|
|
|
|
void PickUpEntry()
|
|
{
|
|
if (examinableItem.examineItem.CanPressButtonToGetItem
|
|
&& examinableItem.examineItem.CurrenltyExaminingObj)
|
|
{
|
|
examinableItem.examineItem.CanPressButtonToGetItem = false;
|
|
StartCoroutine(PickingUpObject());
|
|
}
|
|
}
|
|
|
|
IEnumerator PickingUpObject()
|
|
{
|
|
EntriesManager.GetInstance().AddEntryID(CollectibleEntryNameID);
|
|
|
|
Destroy(_EntryGameObject.gameObject);
|
|
yield return new WaitForSecondsRealtime(0.1f);
|
|
examinableItem.examineItem.GotItemExitDisplayingItem3d();
|
|
if (eventDelegateTriggerOnEntryObtained != null)
|
|
{
|
|
eventDelegateTriggerOnEntryObtained?.OnEventInvoke();
|
|
}
|
|
yield return new WaitForSecondsRealtime(0.1f);
|
|
Destroy(gameObject);
|
|
|
|
}
|
|
}
|