Esempio n. 1
0
        /// <summary>
        /// Tells this AnimationManager to draw all current objects on the given
        /// Graphics object
        /// </summary>
        /// <param name="p_g">the Graphics object onwhich to draw</param>
        public void RunNext(Graphics p_g)
        {
            if (selfTiming)
            {
                if (!fps.TimeElapsed()) return;
                fps.Reset();
                fps.Start();
            }

            int removeIndex = 0; // we need to remember how many completed objects to delete

            // A list of AnimationObjects that have completed on this run
            Sprite[] aoToRemove = new Sprite[animationObjects.Count];

            foreach (Sprite animationObject in animationObjects)
            {   // Run each Sprite in turn
                if (animationObject.RunNext(p_g) == 1) // a return of 1 indicates completion
                {   // Remember to remove this object since it is done
                    aoToRemove[removeIndex++] = (Sprite)(animationObject);
                }
            }

            for (int i = 0; i < removeIndex; i++)
            {   // remove all completed Animation objects from list and
                // call the completion event for each (before removal)
                aoToRemove[i].CallCompletionEvent();
                animationObjects.Remove(aoToRemove[i]);
            }
            if (animationObjects.Count == 0) running = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Add the given animation object to the display list
        /// </summary>
        /// <param name="p_ao">An Sprite to be displayed by manager</param>
        /// <returns>true if successful else fales</returns>
        public bool AddObject(Sprite p_ao)
        {
            if (p_ao.Valid())
            {
                animationObjects.AddLast(p_ao);
                running = true; // if any animation objects are present then animations are running
                return true;
            }

            return false;
        }