30 lines
520 B
C#
30 lines
520 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
[System.Serializable]
|
||
|
|
public class InventorySlot
|
||
|
|
{
|
||
|
|
public ItemData item;
|
||
|
|
[Min(0)] public int amount;
|
||
|
|
|
||
|
|
public InventorySlot(ItemData item, int amount)
|
||
|
|
{
|
||
|
|
this.item = item;
|
||
|
|
this.amount = Mathf.Max(0, amount);
|
||
|
|
}
|
||
|
|
|
||
|
|
public bool IsEmpty()
|
||
|
|
{
|
||
|
|
return item == null || amount <= 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
public string GetDisplayText()
|
||
|
|
{
|
||
|
|
if (IsEmpty())
|
||
|
|
{
|
||
|
|
return "Пусто";
|
||
|
|
}
|
||
|
|
|
||
|
|
return item.itemName + " x" + amount;
|
||
|
|
}
|
||
|
|
}
|