예제 #1
0
        /// <summary>
        /// Static constructor adds lightning bolts in different colors to both frames
        /// </summary>
        static CrashAnimation()
        {
            List <ColorScheme> newFrames = new List <ColorScheme>();

            ColorScheme red    = new ColorScheme(Color.red);
            ColorScheme yellow = new ColorScheme(Color.yellow);

            // Generate first few frames
            newFrames.AddRange(AnimationUtils.InterpolateFrames(red, yellow, 3));
            // Add the way back to the original
            newFrames.AddRange(newFrames.ToArray().Reverse());
            // Double it
            newFrames.AddRange(newFrames.ToArray());
            // Quadruple it
            newFrames.AddRange(newFrames.ToArray());
            // Octuple it
            newFrames.AddRange(newFrames.ToArray());

            for (int i = 0; i < 30; i++)
            {
                newFrames.Add(AnimationUtils.CircularSineWave(Color.red, Color.yellow, i));
            }

            newFrames.AddRange(AnimationUtils.InterpolateFrames(newFrames.Last(), new ColorScheme(Color.black), 10));

            frames = newFrames.ToArray();
        }
        /// <summary>
        /// Helper method that generates all animation frames.
        /// </summary>
        /// <returns></returns>
        private static ColorScheme[] generateAnimationFrames()
        {
            /// Init with sine wave
            ColorScheme[] myReturn = new ColorScheme[40];
            for (int i = 0; i < myReturn.Length; i++)
            {
                myReturn[i] = AnimationUtils.CircularSineWave(new Color(0f, 0f, .2f), new Color(.3f, .3f, 1f), i);
            }

            return(myReturn);
        }