Thanks for the detailed answer. I want to be sure my idea is somewhat similar to yours:
-
Subclass the Pickup class calling it Pickup_PowerUp with one additional variable: **duration **to identify how much time the powerup lasts
-
Subclass the Pickup_PowerUp calling it Pickup_PowerUp_DoubleDamage -> when this Pickup_PowerUp_DoubleDamage is picked up, call Character’s enableDoubleDamage()
The **enableDoubleDamage() **does 3 things
- Sets the Character’s boolean **hasDoubleDamage **to **true **(and this boolean is used to check whether the damage multiplier shall be applied or not)
- The HUD is shown to the Character showing a countdown for the effect of the double damage
- Starts Character’s timer for the double damage. When the Timer expires, the **disableDoubleDamage() **function sets **hasDoubleDamage back to false **and hides the HUD
What if the Character dies?
In that case, I spawn a Pickup_PowerUp_DoubleDamage from the dead character’s position and at the same time I call disableDoubleDamage()
What is the problem?
The problems here are two:
-
Who keeps track of the remaining time of a particular PowerUp? When the player with the PowerUp dies and the new player picks it up, the Timer has to start from where it had ended when the previous owner died…
-
If I have 10 pickups, then I should create 10 booleans for my Character (hasXYZ), 10 timers and 10 enable/disable functions?
Thanks in advance.