Пример #1
0
        public void Update(GameTime time)
        {
            float ts = TimeScale * 6.0f * 0.0167f;

            if (ts > 0)
            {
                GameTime gameTime = new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(ts), TimeSpan.Zero, TimeSpan.FromSeconds(ts));

                if (!playingSkinned)
                {
                    skinnedPlayer.StartClip(skinnedClip, 1, TimeSpan.Zero);

                    rigidPlayer.StartClip(rigidClip, 1, TimeSpan.Zero);

                    playingSkinned = true;

                    if (skinnedRootPlayer != null && skinnedRootClip != null)
                    {
                        skinnedRootPlayer.StartClip(skinnedRootClip, 1, TimeSpan.Zero);
                    }
                    if (rigidRootPlayer != null && rigidRootClip != null)
                    {
                        rigidRootPlayer.StartClip(rigidRootClip, 1, TimeSpan.Zero);
                    }
                }

                // If we are playing skinned animations, update the players
                if (playingSkinned)
                {
                    if (skinnedRootPlayer != null)
                    {
                        skinnedRootPlayer.Update(gameTime);
                    }
                    if (rigidRootPlayer != null)
                    {
                        rigidRootPlayer.Update(gameTime);
                    }

                    skinnedPlayer.Update(gameTime);
                    rigidPlayer.Update(gameTime);
                }
            }
        }
        protected override void Update(GameTime gameTime)
        {
            // Get the current gamepad state and store the old
            lastGamePadState    = currentGamePadState;
            currentGamePadState = GamePad.GetState(PlayerIndex.One);

            lastKeyboardState    = currentKeyboardState;
            currentKeyboardState = Keyboard.GetState();

            // Allows the game to exit
            if (currentGamePadState.Buttons.Back == ButtonState.Pressed ||
                currentKeyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            // When the A button is pressed and we aren't playing the rigid animations, play them
            if ((IsNewButtonPress(Buttons.A) || IsNewKeyPress(Keys.A)) && playingRigid == false)
            {
                if (rigidPlayer != null && rigidClip != null)
                {
                    rigidPlayer.StartClip(rigidClip, 1, TimeSpan.Zero);
                    playingRigid = true;
                }

                if (rigidRootPlayer != null && rigidRootClip != null)
                {
                    rigidRootPlayer.StartClip(rigidRootClip, 1, TimeSpan.Zero);
                    playingRigid = true;
                }
            }

            // When the B button is pressed and we aren't playing the skinned animations, play them
            if ((IsNewButtonPress(Buttons.B) || IsNewKeyPress(Keys.B)) && playingSkinned == false)
            {
                if (skinnedPlayer != null && skinnedClip != null)
                {
                    skinnedPlayer.StartClip(skinnedClip, 1, TimeSpan.Zero);
                    playingSkinned = true;
                }

                if (skinnedRootPlayer != null && skinnedRootClip != null)
                {
                    skinnedRootPlayer.StartClip(skinnedRootClip, 1, TimeSpan.Zero);
                    playingSkinned = true;
                }
            }

            // If we are playing rigid animations, update the players
            if (playingRigid)
            {
                if (rigidRootPlayer != null)
                {
                    rigidRootPlayer.Update(gameTime);
                }

                if (rigidPlayer != null)
                {
                    rigidPlayer.Update(gameTime);
                }
            }

            // If we are playing skinned animations, update the players
            if (playingSkinned)
            {
                if (skinnedRootPlayer != null)
                {
                    skinnedRootPlayer.Update(gameTime);
                }

                if (skinnedPlayer != null)
                {
                    skinnedPlayer.Update(gameTime);
                }
            }

            base.Update(gameTime);
        }