Quantcast
Channel: Questions in topic: "item"
Viewing all articles
Browse latest Browse all 274

Item database with override functions

$
0
0
Hi. What is the best way of creatin item database, which supports "Individual items"? For example, I was using scriptable object for quite time. You can create an item struct and change values of them. But what if item has not only different stats, but also different function? For example: public class ItemConsumable{ public string name; public virtual void consume() { Debug.Log("You have consumed:" + name); } } //Alchogol public class alchogol : ItemConsumable { public alchogol() { name = "Alchogol"; } public override void consume() { base.consume(); Debug.Log("You go drunk"); } } As you can see, the alchogol class overrides ItemConsumable's "consume" function. What is the best way to "Store" items of that type? Can theese classes somehow be added to an array of classes? Thanks.

Viewing all articles
Browse latest Browse all 274

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>