| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- using UnityEngine;
- namespace MazeGen
- {
- /// <summary>
- /// Base class for all equippable/inventory items. Weapons, armor, and consumables
- /// should derive from this. Stored as ScriptableObjects for easy editor configuration.
- /// </summary>
- public abstract class Item : ScriptableObject
- {
- [SerializeField] private string _itemName = "New Item";
- [SerializeField] private string _description = "";
- [SerializeField] private Sprite _icon;
- [SerializeField] private int _rarity = 1; // 1=common, 2=uncommon, 3=rare, 4=epic, 5=legendary
- public string ItemName => _itemName;
- public string Description => _description;
- public Sprite Icon => _icon;
- public int Rarity => _rarity;
- /// <summary>
- /// Called when this item is equipped. Override in subclasses to apply bonuses.
- /// Return false if the item cannot be equipped right now (e.g., armor too heavy for current level).
- /// </summary>
- public virtual bool OnEquip(CharacterSheet character)
- {
- return true;
- }
- /// <summary>Called when this item is unequipped. Override to remove bonuses.</summary>
- public virtual void OnUnequip(CharacterSheet character)
- {
- }
- /// <summary>Short label for UI - override if needed.</summary>
- public virtual string GetLabel() => _itemName;
- public virtual void Use(CharacterSheet character)
- {
- Debug.LogWarning($"Item {ItemName} has no Use() implementation.");
- }
- }
- }
|