Hi guys,
i posted this on unity forums, but i would like to hear your opinion too!
I am implementing the normal/half/double damage mechanics. The way i do it is like this (simplified):
There are two types of weapons:
1. Bullet
2. Energy
Eash type of weapon can be upgraded, so we have something like this:
1. Bullet Level 1 (deals 2 damage)
2. Bullet Level 2 (deals 4 damage)
3. Energy Level 1 (deals 4 damage)
4. Energy Level 2 (deals 8 damage)
There are two types of enemies too:
1. Red enemy - Bullet does normal damage (2 and 4), Energy does half damage (2 and 4)
2. Blue enemy - Bullet does normal damage (2 and 4), Energy does double damage (8 and 16)
Now, when the bullet enters the collider, it is registered by tag (Bullet Level 1, Bullet Level 2, Energy Level 1, Energy Level 2), corresponding to that, damage variable is called and, depending on the enemy type, it is multiplied, divided, or left as it is. This is a fairly simple example, and the total number of combinations is 8. However, when we insert 20 weapons with 4 upgrade levels and 40 types of enemies, things start to look like spaghetti, overly complicated and hard to maintain.
If there would be a possibility to multiple tag the object and to particular number of damage point when a set of tags is recognized it would be much easier, alas, it is not supported (yeah, i know about the stuff on the asset store, but i want to see what other legit way to do this would be. Besides, i think those are useful only for organizing, i wouldn't know how would i compare multiple tags).
The FSM is:
First state:Collision 2D event/Compare Tag
Second state:Int Operator with divide or multiply operator depending on type of damage, or only take damage if there are no modifications.
I would like to hear your opinion