The Situation
Here’s the overall situation. I have a tank object with several hitboxes that are childed to a “hitboxmanager” object. Each hitbox uses an enum identifier to match it to it’s respective part (wheels, body, turret, barrel, etc).
When one of these hitboxes are struck, they report to the hitbox manager:
- Damage was received
- The damage amount
- The part that was hit (the one the individual hitbox is responsible for)
The Idea
Now that’s all well and good. But I am at a loss of how to store the data in the hitbox manager and access it reasonably.
The hitbox manager should, in the ideal situation:
- At Start(), use foreach to create an entry for each distinct enum in the children (may be more than one barrel hitbox, etc) along with an associated float for maximum health, and another float for current health.
- When a child reports they were hit, uses the child’s enum as a key and changes the current health accordingly.
- Sum current health and maximum health of all enum types (as in, the total current health of the object) for a percentage health display on the gui.
The Solution(???)
Now it sounds the best method would be to use a dictionary, but I’ve read that dictionaries don’t show up on the inspector so I can’t monitor it for debugging purposes. And I’ve looked into arrays and lists but those seem to be messy and restrictive (have to search each for the proper value instead of using a key)
I could just declare a boatload of public variables and write a massive if() statement to determine which to edit, but that’s messy and would be a problem with rapid hits and multiple objects in the scene.