40 lines
984 B
C#
40 lines
984 B
C#
using Logic.Data;
|
|
using UnityEngine;
|
|
|
|
namespace Logic.UI
|
|
{
|
|
public class UIInventoryManager : MonoBehaviour
|
|
{
|
|
[SerializeField] private UIInventorySlot[] inventorySlots;
|
|
private void Start()
|
|
{
|
|
inventorySlots = GetComponentsInChildren<UIInventorySlot>();
|
|
}
|
|
|
|
public void Add(Item item)
|
|
{
|
|
foreach (UIInventorySlot inventorySlot in inventorySlots)
|
|
{
|
|
if (!inventorySlot.isFull)
|
|
{
|
|
inventorySlot.AddItem(item);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Remove(Item item)
|
|
{
|
|
foreach (UIInventorySlot inventorySlot in inventorySlots)
|
|
{
|
|
if (inventorySlot.isFull && inventorySlot.item.Equals(item))
|
|
{
|
|
inventorySlot.ClearSlot();
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|