Files
Shopkeeper/Assets/Scripts/Items/ShopItem.cs
Caleb Sandford deQuincey 47944971ca initial game submission
2025-06-10 22:13:25 +01:00

39 lines
910 B
C#

using UnityEngine;
public class ShopItem : MonoBehaviour
{
public ShopItemData data; // Assign in prefab
public float health = 100f; // Per-instance
public int currentStock = 1; // Per-instance
public bool NeedsReplacement => health < 40f;
public void ApplyDamage(float damage)
{
health -= damage;
CheckCondition();
}
public void GradualDecay(float decayRate)
{
if (data.perishable)
{
health -= decayRate;
CheckCondition();
}
}
void CheckCondition()
{
if (health <= 0)
{
GeneralUIController.Instance.ShowMessage($"💥 {data.itemName} is ruined! Removing...");
Destroy(gameObject);
}
else if (health < 40)
{
GeneralUIController.Instance.ShowMessage($"⚠️ {data.itemName} is in poor condition!");
}
}
}