Let's say I have 5 types of bombs. One is explosive, other one is just a smoke bomb so on and so forth. How can I handle this?
I see 2 ways myself. One would be to create different classes that inherits an Item class which would have "cost" and "damage" fields and overriding method named "Use" to use the bomb.
The other one would be to declare a list to hold instances of Item classes which would also contain "cost" and "damage" fields along with a "name" field. In this case I'd have to serialize and deserialize the list every time + I'd have to hardcode an "item manager" script for different uses of each bomb so it may look ugly.
What would you do in this case?
↧