Example #1
0
        public void AnimatePanelShift(float changeZ, TwitchCompleteEvent callback)
        {
            position.Z += changeZ;
            ITransform transform = this as ITransform;

            if (transform != null)
            {
                TwitchManager.Set <float> set = delegate(float value, Object param) { Vector3 trans = transform.Local.Translation; trans.Z = value; transform.Local.Translation = trans; transform.Compose(); };
                TwitchManager.CreateTwitch <float>(transform.Local.Translation.Z, position.Z, set, twitchTime, TwitchCurve.Shape.EaseOut, this, callback);
            }
        }
Example #2
0
        public void TransitionToWaterType(int newType, float transitionTime)
        {
            //check if another transition was running, if so, don't start another
            if (waterTransitioning)
            {
                //already transitioning to this type?  if so, return and let the current transition finish
                if (allTypes[newType] == transitionToDefinition)
                {
                    return;
                }
                StopWaterTransition();
            }

            transitionFromDefinition = definition;
            transitionToDefinition   = allTypes[newType];
            transitionAmount         = 0.0f;
            waterTransitioning       = true;

            //make a copy so we aren't adjusting the real values
            definition = new Definition(definition);

            //since we're moving from 0.0 to 1.0, use the input as the lerp value (even though it won't technically be linear)
            TwitchManager.Set <float> waterLerp = delegate(float value, Object param)
            {
                transitionAmount         = value;
                definition.Color         = transitionFromDefinition.Color * (1.0f - value) + transitionToDefinition.Color * value;
                definition.Emissive      = transitionFromDefinition.Emissive * (1.0f - value) + transitionToDefinition.Emissive * value;
                definition.ExplicitBloom = transitionFromDefinition.ExplicitBloom * (1.0f - value) + transitionToDefinition.ExplicitBloom * value;
                definition.Fresnel       = transitionFromDefinition.Fresnel * (1.0f - value) + transitionToDefinition.Fresnel * value;
                definition.Shininess     = transitionFromDefinition.Shininess * (1.0f - value) + transitionToDefinition.Shininess * value;
                definition.TextureTiling = transitionFromDefinition.TextureTiling * (1.0f - value) + transitionToDefinition.TextureTiling * value;
            };

            TwitchCompleteEvent waterLerpComplete = delegate(Object param)
            {
                definition         = transitionToDefinition;
                waterTransitioning = false;
            };

            TwitchCompleteEvent waterLerpTerminated = delegate(Object param) {};

            waterTwitchId = TwitchManager.CreateTwitch <float>(0.0f, 1.0f, waterLerp, transitionTime, TwitchCurve.Shape.EaseIn, null, waterLerpComplete, waterLerpTerminated, true);
        }
Example #3
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 #4
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()