Пример #1
0
        /// <summary>
        /// Handles the display of currently active animations
        /// </summary>
        /// <param name="e"></param>
        private void DrawAnimations(PaintEventArgs e)
        {
            HashSet <Object> ToRemove = new HashSet <Object>();

            foreach (Object o in ActiveAnimation)
            {
                // Animate explosions
                if (o is Explosion)
                {
                    Explosion exp = o as Explosion;
                    DrawObjectWithTransform(e, exp, theWorld.UniverseSize, exp.location.GetX(), exp.location.GetY(), 0, ExplosionDrawer);
                    if (exp.AnimationFinished())
                    {
                        exp.ticker = 0;
                        ToRemove.Add(exp);
                    }
                }
                // Animate Beams
                else if (o is Beam)
                {
                    Beam b = o as Beam;
                    DrawObjectWithTransform(e, b, theWorld.UniverseSize, b.origin.GetX(), b.origin.GetY(), b.direction.ToAngle(), BeamDrawer);
                    if (b.AnimationFinished())
                    {
                        ToRemove.Add(b);
                    }
                }
            }
            // Stops animating finished animations
            foreach (Object o in ToRemove)
            {
                ActiveAnimation.Remove(o);
            }
        }