示例#1
0
 public MixerParamTweener(AudioMixer mixer, string param, float start, Func <float, float> conv)
 {
     m_Mixer   = mixer;
     m_Param   = param;
     m_Conv    = conv;
     m_Tweener = new ValueTweener(start);
 }
示例#2
0
 /// <summary>
 /// Updates the current state.
 /// </summary>
 /// <param name="tweener">Current tweener instance.</param>
 /// <param name="time">Elapsed time since last frame in seconds.</param>
 /// <returns>
 /// True if the state has been cleared.
 /// </returns>
 public bool Update(ValueTweener tweener, float time)
 {
     this.elapsed += time;
     if (this.elapsed >= this.Duration)
     {
         return true;
     }
     return false;
 }
示例#3
0
 /// <summary>
 /// Updates the current state.
 /// </summary>
 /// <param name="tweener">Current tweener instance.</param>
 /// <param name="time">Elapsed time since last frame in seconds.</param>
 /// <returns>
 /// True if the state has been cleared.
 /// </returns>
 public bool Update(ValueTweener tweener, float time)
 {
     this.elapsed += time;
     if (this.elapsed >= this.Duration)
     {
         return(true);
     }
     return(false);
 }
示例#4
0
        /// <summary>
        ///     Updates the current state.
        /// </summary>
        /// <param name="tweener">Current tweener instance.</param>
        /// <param name="time">Elapsed time since last frame in seconds.</param>
        /// <returns>
        ///     True if the state has been cleared.
        /// </returns>
        public bool Update(ValueTweener tweener, float time)
        {
            elapsed += time;

            var newValue = Tween(elapsed, Start, Finish - Start, Duration);
            if (elapsed >= Duration)
            {
                tweener.Value = Finish;
                return true;
            }
            tweener.Value = newValue;

            return false;
        }
示例#5
0
        /// <summary>
        /// Updates the current state.
        /// </summary>
        /// <param name="tweener">Current tweener instance.</param>
        /// <param name="time">Elapsed time since last frame in seconds.</param>
        /// <returns>
        /// True if the state has been cleared.
        /// </returns>
        public bool Update(ValueTweener tweener, float time)
        {
            this.elapsed += time;

            var newValue = this.Tween(this.elapsed, this.Start, this.Finish - this.Start, this.Duration);

            if (this.elapsed >= this.Duration)
            {
                tweener.Value = this.Finish;
                return(true);
            }
            else
            {
                tweener.Value = newValue;
            }

            return(false);
        }
示例#6
0
        /// <summary>
        /// Initializes the scene
        /// </summary>
        protected override void OnInitialize()
        {
            var resources = AlmiranteEngine.Resources;

            this.images.Add(resources.LoadSync<Texture2D>("Textures/Splash01"));
            this.images.Add(resources.LoadSync<Texture2D>("Textures/Splash02"));

            tweener = new ValueTweener(0, 1);
            tweener.Wait(0.5f).Forward(0.5f).Wait(0.5f).Backward(0.5f);
            tweener.Action(new Action(() =>
            {
                this.imageIndex++;
                if (this.imageIndex > this.images.Count - 1)
                {
                    this.imageIndex = 0;
                }
            }));
            tweener.Repeat(this.images.Count);
            tweener.Action(new Action(() =>
            {
                AlmiranteEngine.Scenes.Push<MainScene>(FadeInTransition.Name, 3.0f);
            }));
        }
示例#7
0
        /// <summary>
        /// Initializes the scene
        /// </summary>
        protected override void OnInitialize()
        {
            var resources = AlmiranteEngine.Resources;

            this.images.Add(resources.LoadSync <Texture2D>("Textures/Splash01"));
            this.images.Add(resources.LoadSync <Texture2D>("Textures/Splash02"));

            tweener = new ValueTweener(0, 1);
            tweener.Wait(0.5f).Forward(0.5f).Wait(0.5f).Backward(0.5f);
            tweener.Action(new Action(() =>
            {
                this.imageIndex++;
                if (this.imageIndex > this.images.Count - 1)
                {
                    this.imageIndex = 0;
                }
            }));
            tweener.Repeat(this.images.Count);
            tweener.Action(new Action(() =>
            {
                AlmiranteEngine.Scenes.Push <MainScene>(FadeInTransition.Name, 3.0f);
            }));
        }
示例#8
0
        /// <summary>
        /// Transitions the push complete.
        /// </summary>
        internal void TransitionPushComplete()
        {
            lock (this)
            {
                if (this.current.Count > 0)
                {
                    this.current.Peek().ClearTransitioning();
                    this.current.Peek().Deactivate();
                }

                if (this.nextScene != null)
                {
                    this.nextScene.ClearTransitioning();

                    if (this.transition != null)
                    {
                        this.transition.Complete();
                    }

                    this.current.Push(this.nextScene);
                    this.nextScene.Enter();
                    this.nextScene.Activate();
                    this.nextScene = null;
                }
                else
                {
                    if (this.transition != null)
                    {
                        this.transition.Complete();
                    }
                }

                this.transitionType  = TransitionType.None;
                this.transitionTween = null;
                this.transition      = null;
            }
        }
示例#9
0
        /// <summary>
        /// Transitions the pop complete.
        /// </summary>
        internal void TransitionPopComplete()
        {
            lock (this)
            {
                this.current.Peek().Deactivate();
                this.current.Peek().ClearTransitioning();
                this.current.Peek().Leave();
                this.current.Pop();

                this.current.Peek();
                this.current.Peek().ClearTransitioning();

                if (this.transition != null)
                {
                    this.transition.Complete();
                }

                this.current.Peek().Activate();

                this.transitionType  = TransitionType.None;
                this.transitionTween = null;
                this.transition      = null;
            }
        }
示例#10
0
 /// <summary>
 /// Scene creation.
 /// </summary>
 protected override void OnInitialize()
 {
     this.font = AlmiranteEngine.Resources.LoadSync<SpriteFont>("Fonts/Small");
     this.fade = new ValueTweener(0.5f, 1);
     this.fade.Forward(0.5f).Backward(0.5f).Repeat();
 }
示例#11
0
 /// <summary>
 /// Scene creation.
 /// </summary>
 protected override void OnInitialize()
 {
     this.font = AlmiranteEngine.Resources.LoadSync <SpriteFont>("Fonts/Small");
     this.fade = new ValueTweener(0.5f, 1);
     this.fade.Forward(0.5f).Backward(0.5f).Repeat();
 }
示例#12
0
        /// <summary>
        /// Setups the transition.
        /// </summary>
        /// <param name="next">The next.</param>
        /// <param name="type">The type.</param>
        /// <param name="name">The name.</param>
        /// <param name="time">The time.</param>
        /// <exception cref="System.Exception">
        /// Cannot pop the only scene on the stack.
        /// or
        /// Invalid transition name:  + name
        /// </exception>
        internal void SetupTransition(Scene next, TransitionType type, string name, float time)
        {
            if (name == null)
            {
                switch (type)
                {
                case TransitionType.Switch:
                    this.nextScene = next;
                    this.TransitionSwitchComplete();
                    break;

                case TransitionType.Push:
                    this.nextScene = next;
                    this.TransitionPushComplete();
                    break;

                case TransitionType.Pop:
                    this.TransitionPopComplete();
                    break;

                default:
                    // do the defalut action
                    break;
                }
            }
            else
            {
                Transition trans = null;
                if (this.transitions.TryGetValue(name, out trans))
                {
                    this.nextScene = next;

                    Scene scene = null;
                    if (this.current.Count > 0)
                    {
                        scene = this.current.Peek();
                        scene.SetTransitioning();
                        scene.Deactivate();
                    }

                    if (type != TransitionType.Pop)
                    {
                        scene = this.nextScene;
                    }
                    else
                    {
                        if (this.current.Count >= 2)
                        {
                            var scenes = this.current.ToArray();
                            scene = scenes[scenes.Length - 2];
                        }
                        else
                        {
                            throw new InvalidOperationException("Cannot pop the only scene on the stack.");
                        }
                    }

                    if (scene != null)
                    {
                        scene.Enter();
                        scene.SetTransitioning();
                    }

                    this.transition = trans;
                    this.transition.Start();

                    this.transitionType = type;

                    this.transitionTween = new ValueTweener(0, 1);
                    if (type == TransitionType.Switch)
                    {
                        this.transitionTween.Forward(time);
                        this.transitionTween.Action(new Action(this.TransitionSwitchComplete));
                        this.transitionTween.Start();
                    }
                    else if (type == TransitionType.Push)
                    {
                        this.transitionTween.Forward(time);
                        this.transitionTween.Action(new Action(this.TransitionPushComplete));
                        this.transitionTween.Start();
                    }
                    else if (type == TransitionType.Pop)
                    {
                        this.transitionTween.Forward(time);
                        this.transitionTween.Action(new Action(this.TransitionPopComplete));
                        this.transitionTween.Start();
                    }
                }
                else
                {
                    throw new InvalidOperationException("Invalid transition name: " + name);
                }
            }
        }
示例#13
0
        /// <summary>
        /// Initializes the scene.
        /// </summary>
        protected override void OnInitialize()
        {
            // Character texture
            var resources = AlmiranteEngine.Resources;
            this.character = resources.LoadAsync<Texture2D>("Textures\\character");

            // Position tweener
            this.position = new Vector2(0, 0);
            this.positionTweener = new VectorTweener(new Vector2(470, 30), new Vector2(720, 180));
            this.positionTweener.ValueChanged += (tween, data) =>
            {
                this.position = tween.Value;
            };

            this.positionTweener.Forward(5, MotionTweens.ElasticInOut).Backward(5, MotionTweens.BounceInOut).Action(() =>
            {
            }).Repeat().Start();

            // Angle tweener
            this.angle = 0;
            this.angleTweener = new ValueTweener(0, MathHelper.ToRadians(360));
            this.angleTweener.ValueChanged += (tweener, data) =>
            {
                this.angle = tweener.Value;
            };

            this.angleTweener.Forward(1).Action(() =>
            {
            }).Repeat().Start();

            // Color tweener
            this.color = Color.White;
            this.colorTweener = new ColorTweener(Color.White, Color.Red);
            this.colorTweener.ValueChanged += (tweener, data) =>
            {
                this.color = tweener.Value;
            };

            this.colorTweener.Forward(0.8f).Backward(0.8f).Action(() =>
            {
            }).Repeat().Start();

            // Positions tweener
            this.positions = new Vector2[8];
            this.positionsTweener = new ValueTweener[8];

            for (int i = 0; i < this.positions.Length; i++)
            {
                this.positions[i] = new Vector2();
                this.positions[i].X = 20;
                this.positions[i].Y = 30 + (50 * i);

                this.positionsTweener[i] = new ValueTweener(this.positions[i].X, this.positions[i].X + 400, i);
                this.positionsTweener[i].ValueChanged += (tween, data) =>
                {
                    this.positions[(int)data].X = tween.Value;
                };
            }

            this.positionsTweener[0].Forward(5).Backward(5).Repeat().Start();
            this.positionsTweener[1].Backward(5).Forward(3).Backward(1).Forward(1).Repeat().Start();
            this.positionsTweener[2].Forward(4).Wait(2).Backward(4).Repeat().Start();
            this.positionsTweener[3].Forward(2).Backward(2).Wait(1).Repeat().Start();
            this.positionsTweener[4].Wait(2).Forward(2).Backward(2).Forward(2, MotionTweens.ElasticInOut).Backward(2, MotionTweens.SinusoidalInOut).Repeat().Start();
            this.positionsTweener[5].Forward(1).Backward(1).Repeat().Start();
            this.positionsTweener[6].Backward(5).Forward(1).Backward(1).Wait(1).Forward(1).Backward(0.5f).Forward(0.5f).Repeat().Start();
            this.positionsTweener[7].Forward(8, MotionTweens.ExponentialInOut).Backward(2, MotionTweens.QuinticInOut).Repeat().Start();

            // this.Almirante.IsCursorVisible = true;
        }
示例#14
0
        /// <summary>
        /// Updates the current state.
        /// </summary>
        /// <param name="tweener">Current tweener instance.</param>
        /// <param name="time">Elapsed time since last frame in seconds.</param>
        /// <returns>
        /// True if the state has been cleared.
        /// </returns>
        public bool Update(ValueTweener tweener, float time)
        {
            this.elapsed += time;

            var newValue = this.Tween(this.elapsed, this.Start, this.Finish - this.Start, this.Duration);
            if (this.elapsed >= this.Duration)
            {
                tweener.Value = this.Finish;
                return true;
            }
            else
            {
                tweener.Value = newValue;
            }

            return false;
        }
示例#15
0
 /// <summary>
 /// Updates the current state.
 /// </summary>
 /// <param name="tweener">Current tweener instance.</param>
 /// <param name="time">Elapsed time since last frame in seconds.</param>
 /// <returns>
 /// True if the state has been cleared.
 /// </returns>
 public bool Update(ValueTweener tweener, float time)
 {
     return(true);
 }
示例#16
0
 /// <summary>
 /// Updates the current state.
 /// </summary>
 /// <param name="tweener">Current tweener instance.</param>
 /// <param name="time">Elapsed time since last frame in seconds.</param>
 /// <returns>
 /// True if the state has been cleared.
 /// </returns>
 public bool Update(ValueTweener tweener, float time)
 {
     return true;
 }
示例#17
0
        /// <summary>
        /// Initializes the scene.
        /// </summary>
        protected override void OnInitialize()
        {
            // Character texture
            var resources = AlmiranteEngine.Resources;

            this.character = resources.LoadAsync <Texture2D>("Textures\\character");

            // Position tweener
            this.position        = new Vector2(0, 0);
            this.positionTweener = new VectorTweener(new Vector2(470, 30), new Vector2(720, 180));
            this.positionTweener.ValueChanged += (tween, data) =>
            {
                this.position = tween.Value;
            };

            this.positionTweener.Forward(5, MotionTweens.ElasticInOut).Backward(5, MotionTweens.BounceInOut).Action(() =>
            {
            }).Repeat().Start();

            // Angle tweener
            this.angle        = 0;
            this.angleTweener = new ValueTweener(0, MathHelper.ToRadians(360));
            this.angleTweener.ValueChanged += (tweener, data) =>
            {
                this.angle = tweener.Value;
            };

            this.angleTweener.Forward(1).Action(() =>
            {
            }).Repeat().Start();

            // Color tweener
            this.color        = Color.White;
            this.colorTweener = new ColorTweener(Color.White, Color.Red);
            this.colorTweener.ValueChanged += (tweener, data) =>
            {
                this.color = tweener.Value;
            };

            this.colorTweener.Forward(0.8f).Backward(0.8f).Action(() =>
            {
            }).Repeat().Start();

            // Positions tweener
            this.positions        = new Vector2[8];
            this.positionsTweener = new ValueTweener[8];

            for (int i = 0; i < this.positions.Length; i++)
            {
                this.positions[i]   = new Vector2();
                this.positions[i].X = 20;
                this.positions[i].Y = 30 + (50 * i);

                this.positionsTweener[i] = new ValueTweener(this.positions[i].X, this.positions[i].X + 400, i);
                this.positionsTweener[i].ValueChanged += (tween, data) =>
                {
                    this.positions[(int)data].X = tween.Value;
                };
            }

            this.positionsTweener[0].Forward(5).Backward(5).Repeat().Start();
            this.positionsTweener[1].Backward(5).Forward(3).Backward(1).Forward(1).Repeat().Start();
            this.positionsTweener[2].Forward(4).Wait(2).Backward(4).Repeat().Start();
            this.positionsTweener[3].Forward(2).Backward(2).Wait(1).Repeat().Start();
            this.positionsTweener[4].Wait(2).Forward(2).Backward(2).Forward(2, MotionTweens.ElasticInOut).Backward(2, MotionTweens.SinusoidalInOut).Repeat().Start();
            this.positionsTweener[5].Forward(1).Backward(1).Repeat().Start();
            this.positionsTweener[6].Backward(5).Forward(1).Backward(1).Wait(1).Forward(1).Backward(0.5f).Forward(0.5f).Repeat().Start();
            this.positionsTweener[7].Forward(8, MotionTweens.ExponentialInOut).Backward(2, MotionTweens.QuinticInOut).Repeat().Start();

            // this.Almirante.IsCursorVisible = true;
        }