Example #1
0
        }   // end of SetOrientation()

        /// <summary>
        /// Smoothly changes the orientation from the current values to the new.
        /// </summary>
        /// <param name="o"></param>
        public void TwitchOrientation(Orientation o)
        {
            TwitchCurve.Shape shape      = TwitchCurve.Shape.OvershootOut;
            float             twitchTime = 0.25f;

            if (Level == null)
            {
                return;
            }

            Orientation cur = orientation;

            // Rotation
            if (twitchOrientation.rotation != o.rotation)
            {
                twitchOrientation.rotation = o.rotation;
                TwitchManager.Set <float> set = delegate(float val, Object param) { cur.rotation = val; };
                TwitchManager.CreateTwitch <float>(cur.rotation, o.rotation, set, twitchTime, shape);
            }
            // Scale
            if (twitchOrientation.scale != o.scale)
            {
                twitchOrientation.scale = o.scale;
                TwitchManager.Set <float> set = delegate(float val, Object param) { cur.scale = val; };
                TwitchManager.CreateTwitch <float>(cur.scale, o.scale, set, twitchTime, shape);
            }
            // Position
            if (twitchOrientation.position != o.position)
            {
                twitchOrientation.position = o.position;
                TwitchManager.Set <Vector3> set = delegate(Vector3 val, Object param) { cur.position = val; };
                TwitchManager.CreateTwitch <Vector3>(cur.position, o.position, set, twitchTime, shape);
            }
        }   // TwitchedOrientation()
Example #2
0
        }   // end of UIElement Update()

        /// <summary>
        /// Change the position value using a twitch.
        /// </summary>
        /// <param name="finalValue">Destination value.</param>
        /// <param name="twitchTime">Time in seconds for twitch.</param>
        /// <param name="twitchShape">Animation curve shape to apply to twitch.</param>
        public void TwitchPosition(Vector3 finalValue, float twitchTime, TwitchCurve.Shape twitchShape)
        {
            if (twitchTime > 0.0f)
            {
                TwitchManager.Set <Vector3> set = delegate(Vector3 value, Object param) { Position = value; };
                TwitchManager.CreateTwitch <Vector3>(Position, finalValue, set, twitchTime, twitchShape);
            }
            else
            {
                // No time, just set the result.
                position = finalValue;
            }
        }   // end of UIGridElement TwitchPosition()
Example #3
0
        }   // end of UIGridElement TwitchScale()

        /// <summary>
        /// Change the grey value using a twitch.
        /// </summary>
        /// <param name="finalValue">Destination value.</param>
        /// <param name="twitchTime">Time in seconds for twitch.</param>
        /// <param name="twitchShape">Animation curve shape to apply to twitch.</param>
        public void TwitchGrey(float finalValue, float twitchTime, TwitchCurve.Shape twitchShape)
        {
            if (twitchTime > 0.0f)
            {
                if (targetGrey != finalValue)
                {
                    // Create a twitch to change grey in baseColor
                    TwitchManager.Set <float> set = delegate(float value, Object param) { Grey = value; };
                    TwitchManager.CreateTwitch <float>(Grey, finalValue, set, twitchTime, twitchShape);

                    targetGrey = finalValue;
                }
            }
            else
            {
                // No time, just set the result.
                grey       = finalValue;
                targetGrey = finalValue;
            }
        }   // end of UIGridElement TwitchGrey()
Example #4
0
 /// <summary>
 /// Creates and starts a twitch.
 /// </summary>
 /// <typeparam name="T">The type of twitch.</typeparam>
 /// <param name="startValue"></param>
 /// <param name="targetValue"></param>
 /// <param name="set">Set delegate called each frame to set the current value.</param>
 /// <param name="duration">Time for twitch to take.</param>
 /// <param name="shape">Curve shape.</param>
 /// <param name="param">User defined param used w/ onComplete</param>
 /// <param name="onComplete">Event handler triggered when twitch completes.</param>
 /// <param name="useGameTime">By default twitches used WallClockTime since they're generally used for UI.  Set this to true if you want the twitch to run off of GameTime</param>
 public static int CreateTwitch <T>(T startValue, T targetValue, Set <T> set, double duration, TwitchCurve.Shape shape, Object param, TwitchCompleteEvent onComplete, bool useGameTime) where T : struct
 {
     return(Twitch <T> .CreateTwitch(startValue, targetValue, set, duration, shape, param, onComplete, null, useGameTime));
 }
Example #5
0
        //
        // CreateTwitch methods.  These should be the only public interface...
        //

        /// <summary>
        /// Creates and starts a twitch.
        /// </summary>
        /// <typeparam name="T">The type of twitch.</typeparam>
        /// <param name="startValue"></param>
        /// <param name="targetValue"></param>
        /// <param name="set">Set delegate called each frame to set the current value.</param>
        /// <param name="duration">Time for twitch to take.</param>
        /// <param name="shape">Curve shape.</param>
        public static int CreateTwitch <T>(T startValue, T targetValue, Set <T> set, double duration, TwitchCurve.Shape shape) where T : struct
        {
            return(Twitch <T> .CreateTwitch(startValue, targetValue, set, duration, shape, null, null, null, false));
        }
Example #6
0
            public static int CreateTwitch(T startValue, T targetValue, Set <T> set, double duration, TwitchCurve.Shape shape, Object param, TwitchCompleteEvent onComplete, TwitchCompleteEvent onTerminate, bool useGameTime)
            {
                // Get the next free twitch.
                // If none exists, create it.
                Twitch <T> twitch = null;

                if (freeList.Count > 0)
                {
                    twitch = freeList[freeList.Count - 1];
                    freeList.RemoveAt(freeList.Count - 1);
                }
                else
                {
                    twitch = new Twitch <T>();
                }

                twitch.startValue  = startValue;
                twitch.targetValue = targetValue;
                twitch.set         = set;
                twitch.duration    = duration;
                twitch.shape       = shape;
                twitch.param       = param;
                twitch.Completed   = onComplete;
                twitch.Terminated  = onTerminate;
                twitch.useGameTime = useGameTime;
                twitch.handle      = gTwitchHandle++;
                twitch.terminate   = false;

                twitch.startTime = useGameTime ? Time.GameTimeTotalSeconds : Time.WallClockTotalSeconds;

                // Add the twitch to the active list.
                activeList.Add(twitch);

                return(twitch.handle);
            }   // end of CreateTwitch()