41 lines
969 B
C#
41 lines
969 B
C#
using UnityEngine;
|
|
using TMPro; // Might use TextMeshPro later for labels, just in case
|
|
|
|
namespace MedievalShopkeeper
|
|
{
|
|
public class StockBox : MonoBehaviour
|
|
{
|
|
[Header("Stock Info")]
|
|
public ItemData itemData;
|
|
public int quantity;
|
|
|
|
public void Initialize(ItemData item, int amount)
|
|
{
|
|
itemData = item;
|
|
quantity = amount;
|
|
UpdateVisuals();
|
|
}
|
|
|
|
public void RemoveQuantity(int amount)
|
|
{
|
|
quantity -= amount;
|
|
if (quantity <= 0)
|
|
{
|
|
// Box is empty, destroy it
|
|
Destroy(gameObject);
|
|
}
|
|
else
|
|
{
|
|
UpdateVisuals();
|
|
}
|
|
}
|
|
|
|
private void UpdateVisuals()
|
|
{
|
|
// Future: update a UI text label on the box showing quantity/icon
|
|
gameObject.name = $"StockBox_{itemData?.itemName}_{quantity}";
|
|
}
|
|
}
|
|
}
|
|
|