so i’m working on a battle system and i’ve heard that enums can be used to create different attack types and different types of damage. i know that you can create an enumaration and create a list of the different types within it and use the switch to apply them. my question is, how do you determine which fires? i want heavy damage to fire when a heavy weapon hits and i want fast damage to fire when a fast weapon hits. i hope ive explained this properly, i cant seem to find any doc on how to use enums
first need create a enum:
light damage, heavy damage…
And when you get the damage using a a switch to route the signal:
So how is this used upon inflicting the damage. Sorry I’m just trying to make sure I completely understand the entire concept. I can store the damage type within an array and then use the bottom picture to switch between them by changing the Index according to what type I want? So when I inflict damage, I send over the damage amount which would be a float variable. At the same time I can send over the Enum index number which basically says that the inflicting damage is _____ damage?
Enum is basically a simple list/enumeration/array of indexed titles and nothing more. It’s very basic and look like this:
You can work with indexes or with titles, so yes, you can “send” damage with Enum variable, but actually it’s just a byte(index). You can make switch, based on your type/title, but it’s just a simple switch and nothing more
Okay, that makes sense! I think I fully understand now! Thanks!
Yes, We use enums because it is more easy to understand the code when you are working in it.
BTW you would check damage types class is a better way to work with diferentes damages.