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.
↧