46 lines
1.0 KiB
C#
46 lines
1.0 KiB
C#
using Logic.Inventory.Scripts;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Logic.UI
|
|
{
|
|
public class UIInventorySlot : MonoBehaviour
|
|
{
|
|
[SerializeField] private Image icon;
|
|
public ItemObject itemObject;
|
|
public bool isFull;
|
|
|
|
public void AddItem(ItemObject newItem)
|
|
{
|
|
itemObject = newItem;
|
|
SetIcon(newItem);
|
|
isFull = true;
|
|
}
|
|
|
|
public void ClearSlot()
|
|
{
|
|
itemObject = null;
|
|
icon.sprite = null;
|
|
icon.enabled = false;
|
|
isFull = false;
|
|
}
|
|
|
|
private void SetIcon(ItemObject newItem)
|
|
{
|
|
if (newItem.type == ItemType.Food)
|
|
{
|
|
icon.sprite = newItem.foodIcon;
|
|
}
|
|
else if (newItem.type == ItemType.Recipe)
|
|
{
|
|
icon.sprite = newItem.recipeIcon;
|
|
}
|
|
else
|
|
{
|
|
icon.sprite = newItem.moneyIcon;
|
|
}
|
|
icon.enabled = true;
|
|
}
|
|
}
|
|
}
|