Files
MedievalShopkeeper/Assets/Scripts/StockBox.cs

41 lines
969 B
C#
Raw Normal View History

2026-09-03 16:35:05 +01:00
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}";
}
}
}