39 lines
1014 B
C#
39 lines
1014 B
C#
using Kryz.CharacterStats.Examples;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class EquippableItemDrop : Interactable
|
|
{
|
|
public ItemInstance itemDrop;
|
|
[Header("Visuals")]
|
|
public GameObject visuals;
|
|
public ParticleSystem particles;
|
|
|
|
bool waitingForDestroy = false;
|
|
|
|
public override void Interact(bool melee)
|
|
{
|
|
base.Interact(melee);
|
|
|
|
Debug.Log("Interacting with item: " + this.name + " " + itemDrop.ItemName);
|
|
|
|
if (waitingForDestroy) return;
|
|
|
|
if (FindObjectOfType<Inventory>().AddItem(itemDrop))
|
|
{
|
|
waitingForDestroy = true;
|
|
Debug.Log("Interacting with item: " + this.name + " " + itemDrop.ItemName + " found inventory and added it");
|
|
StartCoroutine(PickupEffect());
|
|
}
|
|
|
|
}
|
|
IEnumerator PickupEffect()
|
|
{
|
|
visuals.SetActive(false);
|
|
particles.Play();
|
|
yield return new WaitForSeconds(1f);
|
|
Destroy(this.gameObject);
|
|
}
|
|
}
|