I’m basically trying to implement the Unreal Tournament’s UDamage, Adrenaline and Invisibility PowerUps that anyone in the level can take.
What I already have is a Pickup class which works for weapons, ammo, health and armor.
The rules for PowerUps are the following:
- Only one player at a time can have the same PowerUp [HR][/HR]
- The PowerUp has a global lifetime: once it is picked up, it lasts X seconds no matter how many owners it will encounter
- [HR][/HR]The PowerUp’s lifetime is displayed to the owner player from a HUD. When the owner player dies or the PowerUp expires, the HUD must be removed
My idea was to:
- Write 3 methods for the Character: SetDoubleDamage(bool), SetAdrenaline(bool), SetInvisibility(bool) - these methods would be called from the Pickup class [HR][/HR]
- Keep track of the lifetime of each PowerUp in the GameMode with a float (PowerUpLifetime) [HR][/HR]
- Hold a Timer in the GameState which determines the expiration of each (taken) PowerUp
But then, I though “what if I want to add a new PowerUp in the future? O maybe other 3 PowerUps?”
Then I will have to write X more methods for the Character, keep X more lifetime floats in the GameMode and hold X more timers in the GameState.
I don’t even know if it is correct to keep the lifetime floats in the GameMode and the Timers in the GameState.
I’m looking for advice about this. It’s mostly about “where to place the things” and “who should keep track of what”.
Thank you in advance.