Game Development Reference
In-Depth Information
_effects.ForEach(x = > x.Update(elapsedTime));
RemoveDeadExplosions();
}
public void Render(Renderer renderer)
{
_effects.ForEach(x = > renderer.DrawSprite(x));
}
private void RemoveDeadExplosions()
{
for (int i ΒΌ _effects.Count - 1; i > = 0; i-)
{
if (_effects[i].Finished)
{
_effects.RemoveAt(i);
}
}
}
}
}
This EffectManager allows an explosion to be set off, runs the explosion ani-
mation until it ends, and then removes the explosion effect. You may notice it's
very similar to the BulletManager class. These separate managers could all be
combined in one generalized manager, but by keeping them separate,
the interactions between the game objects can be specific and more efficient.
Explosions don't care about collision detection with enemies or players but bullets
do. In separate managers, it's easy to separate out the particular requirements of
each object; explosions only need to run an animation, whereas bullets need to
check for intersection with all of the enemies. Separate managers work great when
only a limited number of objects are in the game, but if there are going to be many
different entities, then a more generalized entity manager is a better choice.
The EffectsManager needs to be initialized in the Level class and hooked
up to the render and update loops.
EffectsManager _effectsManager;
public Level(Input input, TextureManager textureManager, PersistantGa-
meData gameData)
 
Search WWH ::




Custom Search