예제 #1
0
        // Update In Scene: Animate
        public override void Update()
        {
            base.Update();

            // Remove from the scene after animating and holding
            if (GetElapsedTime() > TimeBeforeDisable)
            {
                Scene.Remove(this);
            }

            // Also lerp the whole text with time
            float time = GetElapsedTime();

            if (State == TurnSwitchAnimationState.Entry)
            {
                float maxtime = TimeBeforeMiddle;
                float dist    = ((maxtime - time) / maxtime);
                X  = Game.Instance.HalfWidth;
                X += (dist * Game.Instance.Width);

                Text_Label.Shader.SetParameter("time", time / maxtime);
                Text_Label.ScaleX = 1 + dist;

                if (time >= maxtime)
                {
                    State = TurnSwitchAnimationState.Middle;
                }
            }
            if (State == TurnSwitchAnimationState.Middle)
            {
                time -= TimeBeforeMiddle;
                float maxtime = TimeBeforeLeave;
                X = Game.Instance.HalfWidth;

                Text_Label.Shader.SetParameter("time", 1);

                if (time >= maxtime)
                {
                    State = TurnSwitchAnimationState.Exit;
                }
            }
            if (State == TurnSwitchAnimationState.Exit)
            {
                time -= TimeBeforeMiddle + TimeBeforeLeave;
                float maxtime = TimeBeforeMiddle;
                float dist    = 1 - ((maxtime - time) / maxtime);
                X  = Game.Instance.HalfWidth;
                X -= (dist * Game.Instance.Width);

                Text_Label.Shader.SetParameter("time", 1 - (time / maxtime));
                Text_Label.ScaleX = 1 + dist;

                if (time >= maxtime)
                {
                    State = TurnSwitchAnimationState.Entry;
                    Scene.Remove(this);
                }
            }
        }
예제 #2
0
        // Called when turn switches: To reset and begin playing the animation
        public void Initialise()
        {
            Scene_Game scene = (Scene_Game)Scene;

            if (scene.CurrentPlayers.Count == 0)
            {
                return;
            }

            int           player = scene.GetPlayerTurn();
            CommanderType com    = scene.CurrentPlayers.ElementAt(player).Commander;

            Text_Label.Color  = new Color(com.Colour);
            Text_Label.String = String.Format(Label, com.PlayerName.ToUpper());
            Text_Label.CenterOrigin();

            EnabledTime = Game.Instance.Timer;
            State       = TurnSwitchAnimationState.Entry;
        }