예제 #1
0
        /// <summary>Changes the framerate of this animation.</summary>
        public void ChangeFrameRate(int newRate)
        {
            FrameRate = newRate;

            // For each actively running animation..
            if (FirstInstance != null)
            {
                // What's the delay in seconds of a frame?
                float newDelay = 1f / (float)FrameRate;

                // For each..
                SPAInstance current = FirstInstance;

                while (current != null)
                {
                    if (current.Animation == this)
                    {
                        current.FrameDelay = newDelay;
                    }

                    // Hop to the next one:
                    current = current.InstanceAfter;
                }
            }
        }
예제 #2
0
 public override void GoingOffDisplay()
 {
     if (Animation != null)
     {
         Animation.Stop();
         Animation = null;
     }
 }
예제 #3
0
        public override void GoingOnDisplay(Css.RenderableData context)
        {
            if (Animation == null && SPAFile != null)
            {
                Animation = SPAFile.GetInstance();

                // Set the event context now:
                Animation.SetContext(context);
            }
        }
예제 #4
0
        /// <summary>Gets how many animations are actively playing.</summary>
        /// <returns>The number of animations currently playing.</returns>
        public static int ActiveCount()
        {
            int         count   = 0;
            SPAInstance current = FirstInstance;

            while (current != null)
            {
                count++;
                current = current.InstanceAfter;
            }
            return(count);
        }
예제 #5
0
        /// <summary>Advances playback of any running animations and performs some garbage collection.
        /// Called by <see cref="UI.Update"/>.</summary>
        public static void Update(float deltaTime)
        {
            // Advance any active animations.

            // These are all animations in our Instance chain.
            if (FirstInstance != null)
            {
                SPAInstance current = FirstInstance;

                while (current != null)
                {
                    current.Update(deltaTime);
                    current = current.InstanceAfter;
                }
            }
        }
예제 #6
0
        /// <summary>A shortcut for instancing it.</summary>
        public Material Start(Shader shader)
        {
            if (SPAFile == null)
            {
                throw new Exception("Tried to load a broken SPA.");
            }

            if (Animation == null)
            {
                Animation = SPAFile.GetInstance();
            }

            // Setup using the given shader:
            Animation.Setup(shader);

            return(Animation.AnimatedMaterial);
        }
예제 #7
0
        /// <summary>Creates a playable instance of this animation.
        /// Instances are required as the same animation could be visible multiple times.</summary>
        /// <returns>A playable form of this animation.</returns>
        public SPAInstance GetInstance()
        {
            // Create the instance:
            SPAInstance instance = new SPAInstance(this);

            // Push the instance to the global animate queue.
            if (FirstInstance == null)
            {
                FirstInstance = LastInstance = instance;
            }
            else
            {
                instance.InstanceBefore = LastInstance;
                LastInstance            = LastInstance.InstanceAfter = instance;
            }
            return(instance);
        }
예제 #8
0
 /// <summary>Clears all active SPA animations.</summary>
 public static void Clear()
 {
     LastInstance = FirstInstance = null;
 }