Edit: Here is my item system so far (I just included MeleeWeapon because I didn't want this to get too long).
public abstract class Item {
[Header("Basic Info")]
[SerializeField] private string name = "";
[SerializeField] private Image icon = null;
[SerializeField] private GameObject itemPrefab = null;
[SerializeField] private float weight = 0;
[SerializeField] private int maxStack = 0;
private Guid gUID;
public string Name => name;
public Image Icon => icon;
public GameObject ItemPrefab => itemPrefab;
public float Weight => weight;
public int MaxStack => maxStack;
public Guid GUID { get { return gUID; } private set { gUID = Guid.NewGuid(); } }
}
public abstract class Weapon : Item {
public abstract void Attack();
}
[System.Serializable]
public class MeleeWeapon : Weapon {
[Header("Weapon Attributes")]
[SerializeField] private MeleeWeaponTypes weaponType = default;
[SerializeField] private float damage = 0;
[SerializeField] private float chargeDamage = 0;
[SerializeField] private float meleeSpeed = 0;
[SerializeField] private float chargeTime = 0;
[SerializeField] private float chargeCooldown = 0;
public MeleeWeaponTypes WeaponType => weaponType;
public float Damage => damage;
public float ChargeDamage => chargeDamage;
public float MeleeSpeed => meleeSpeed;
public float ChargeTime => chargeTime;
public float ChargeCooldown => chargeCooldown;
public override void Attack() {
// attack
}
}
I have other stuff in Weapon and its derivatives but I removed it to keep the base idea more simple. Anyway, I then have prefabs with a MonoBehaviour that hold a derived type of Item, like I showed above, as data containers that I use to instantiate items during runtime.