30 lines
809 B
C#
30 lines
809 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LootButton : MonoBehaviour
|
|
{
|
|
[Header("Config")]
|
|
[SerializeField] private Image itemIcon;
|
|
[SerializeField] private TextMeshProUGUI itenName;
|
|
[SerializeField] private TextMeshProUGUI itenQuantity;
|
|
|
|
public DropItem ItemLoaded { get; private set; }
|
|
|
|
public void ConfigLootButton(DropItem dropItem)
|
|
{
|
|
ItemLoaded = dropItem;
|
|
itemIcon.sprite = dropItem.Item.Icon;
|
|
itenName.text = dropItem.Item.Name;
|
|
itenQuantity.text = $"x{dropItem.Quantity.ToString()}";
|
|
}
|
|
|
|
public void CollectItem()
|
|
{
|
|
if (ItemLoaded == null) return;
|
|
Inventory.Instance.AddItem(ItemLoaded.Item, ItemLoaded.Quantity);
|
|
ItemLoaded.PickedItem = true;
|
|
Destroy(gameObject);
|
|
}
|
|
}
|