I’m trying to create an item generation system and I’m not sure how I should structure it. First I had an Item
class which had every stat an equippable item (that I had implemented so far) could have, like damage
for weapons, defense
for gear, etc., and it worked fine, but I wasn’t sure if that was the best way to go about it since the list would get bigger and more abstract the more items I made, and each item that was generated had every single stat that other items could have so it was this long list of 0s in the inspector with only a few variables changed/useable. How it looked wasn’t really the problem, it’s more that I wasn’t sure if having each item so closely related (using the same script) was a good idea.
After that I tried something else and made the original Item
class abstract, and put a few variables, like rarity, in there that other classes would inherit from. I then had classes like RangedWeapon
, Melee Weapon
, Accessory
, etc., which would still work, but it made the code very tedious as I then have to generate the item type, then change what script it gets depending on what item it generates, so I’d end up with this long switch statement with a bunch of different lines for each item type.
I can provide examples if the above was hard to understand, but other than that if anyone has any suggestions or knows common methods game developers use then please let me know.