Right now, we have a single powerup and the handling of that powerup is done directly inside player controller. We would like to further support new use-cases:
Multiple types of effects, such as clone reversal
Possibility of status item becoming usable again after a delay
Adding a visual feedback of status effect being applied, such as a hovering icon above the head
Hence, the following refactoring is desired: Segregation of logic between "status effect items" and the "application of effects on player/clone".
Possible approach (feel free to suggest)
[x] New component on Player.prefab called ReceiveStatusEffect that provides an public method: ApplyEffect(enum type, float duration, optional float value)
Revert changes in player controller, instead the ReceiveStatusEffect should hold a pointer to PlayerController and make the changes as an "external" agent
[x] SpeedBoost prefab to contain a new component ApplyStatusEffect that can be configured with the type of effect, the value and duration.
Collisions checks with the player/clone should be handled here. On collision, invoke the ReceiveStatusEffect.ApplyEffect for the collided body
Disable the effect as its used. Now we can also support a way to re-enable the effect after a delay if we want.
[x] New status effect FlipMovement that is a VARIANT of speed boost, with changes made to ApplyStatusEffect fields as relevant.
We can create an enum with different status effects, for now we have two effects "SPEED_BOOST" and "FLIP_DIRECTION".
Right now, we have a single powerup and the handling of that powerup is done directly inside player controller. We would like to further support new use-cases:
Hence, the following refactoring is desired: Segregation of logic between "status effect items" and the "application of effects on player/clone".
Possible approach (feel free to suggest)
Player.prefab
calledReceiveStatusEffect
that provides an public method:ApplyEffect(enum type, float duration, optional float value)
ReceiveStatusEffect
should hold a pointer toPlayerController
and make the changes as an "external" agentSpeedBoost
prefab to contain a new componentApplyStatusEffect
that can be configured with the type of effect, the value and duration.ReceiveStatusEffect.ApplyEffect
for the collided bodyFlipMovement
that is a VARIANT of speed boost, with changes made toApplyStatusEffect
fields as relevant.We can create an enum with different status effects, for now we have two effects "SPEED_BOOST" and "FLIP_DIRECTION".