Udell Games creates an awesome effect manager.
Udell games says:
"
In Hyper Gauntlet, I have recently implemented a vignette system for the edges of the screen. Vignettes are coloured based on the changing game state, with a slow blue fade in and out during slow motion and a red flash when you hit an obstacle. Originally I tweened between colours as needed, but I soon met errors in common scenarios when the vignette colour must tween back to a previous effect colour. As an example, imagine an obstacle is approaching fast. I hold space to engage the slow motion, and a blue vignette appears around the screen. Unfortunately, I cannot move out of the way in time and I hit the obstacle – causing the vignette to fade quickly to red. In a basic system, the vignette would then fade back to a neutral state, instead of returning to the blue to signify that slow motion was still engaged, and this confuses players. Today I present a simple solution tailored for Unity systems that is applicable to any code base. It’s not just useful for vignetting either, I intend to also apply this system to slow motion (to apply power up-induced slow motion even when the player lets go of space for manual slow motion), and this could also find a use in stacking effect spells in RPGs.
"
But that's not all...
"
EffectLet’s start with the simplest class. It’s an effect. It doesn’t really do much at all, you’re meant to extend from it or any of its derived classes with your own, more specialised classes. Effect acts as a catchall for all effects so that they can all be processed. It does support events for tweening in though, as all effects can be gradually applied.
"
Udell games says:
"
In Hyper Gauntlet, I have recently implemented a vignette system for the edges of the screen. Vignettes are coloured based on the changing game state, with a slow blue fade in and out during slow motion and a red flash when you hit an obstacle. Originally I tweened between colours as needed, but I soon met errors in common scenarios when the vignette colour must tween back to a previous effect colour. As an example, imagine an obstacle is approaching fast. I hold space to engage the slow motion, and a blue vignette appears around the screen. Unfortunately, I cannot move out of the way in time and I hit the obstacle – causing the vignette to fade quickly to red. In a basic system, the vignette would then fade back to a neutral state, instead of returning to the blue to signify that slow motion was still engaged, and this confuses players. Today I present a simple solution tailored for Unity systems that is applicable to any code base. It’s not just useful for vignetting either, I intend to also apply this system to slow motion (to apply power up-induced slow motion even when the player lets go of space for manual slow motion), and this could also find a use in stacking effect spells in RPGs.
"
But that's not all...
"
EffectLet’s start with the simplest class. It’s an effect. It doesn’t really do much at all, you’re meant to extend from it or any of its derived classes with your own, more specialised classes. Effect acts as a catchall for all effects so that they can all be processed. It does support events for tweening in though, as all effects can be gradually applied.
"
public class Effect
{
public float TweenInTime =0;
public event EventHandler OnTweenInBegin; //invoked when the effect begins tweening in
public void BeginTweenIn()
{
EventHandler handler = OnTweenInBegin;
if(handler!= null)
{
handler(this,new TweenEventArgs(Value,TweenInTime));
}
}
public Effect()
{
}
public Effect(V value)
{
this.Value = value;
}
public V Value; //The final value (after tweening) to set the property we're affecting to.
}
That's all great but that's not half of it. There's more to know about how they created this "Effect Manager". You can read there actual post here: Effect Manager.
The post includes a lot more information and a lot more example code. So check it out! I did! :)
The post includes a lot more information and a lot more example code. So check it out! I did! :)