当前位置: 首页>>代码示例>>C#>>正文


C# GameTime.GetSeconds方法代码示例

本文整理汇总了C#中Microsoft.Xna.Framework.GameTime.GetSeconds方法的典型用法代码示例。如果您正苦于以下问题:C# GameTime.GetSeconds方法的具体用法?C# GameTime.GetSeconds怎么用?C# GameTime.GetSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.Xna.Framework.GameTime的用法示例。


在下文中一共展示了GameTime.GetSeconds方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        public override void Update(GameTime gameTime)
        {
            var inputSystem = GameProvider.GameInstance.GetService<InputSystem>();
            var currentMouseState = Mouse.GetState();

            var movementDirection = Vector3.Zero;
            if (inputSystem.Left(InputDetectionType.HeldDown, DirectionalInputTypes.WASD | DirectionalInputTypes.LeftThumbstick))
            {
                movementDirection.X = -1.0f;
            }
            else if (inputSystem.Right(InputDetectionType.HeldDown, DirectionalInputTypes.WASD | DirectionalInputTypes.LeftThumbstick))
            {
                movementDirection.X = 1.0f;
            }

            if (inputSystem.Up(InputDetectionType.HeldDown, DirectionalInputTypes.WASD | DirectionalInputTypes.LeftThumbstick))
            {
                movementDirection.Z = 1.0f;
            }
            else if (inputSystem.Down(InputDetectionType.HeldDown, DirectionalInputTypes.WASD | DirectionalInputTypes.LeftThumbstick))
            {
                movementDirection.Z = -1.0f;
            }

            switch (MovementMode)
            {
                case PlayerMovementMode.FirstPerson:
                    HandleFirstPersonMovement(gameTime.GetSeconds(), currentMouseState, movementDirection);
                    break;
                case PlayerMovementMode.ThirdPerson:
                    HandleThirdPersonMovement(gameTime.GetSeconds(), currentMouseState, movementDirection);
                    break;
                case PlayerMovementMode.GodMode:
                    HandleGodModeMovement(gameTime.GetSeconds(), currentMouseState, movementDirection);
                    break;
            }

            _mouseState = currentMouseState;

            if (MovementMode != PlayerMovementMode.GodMode)
            {
                if (Math.Abs(_cameraTargetPosition.Z - ReferringEntity.Position.Z) > float.Epsilon)
                {
                    ReferringEntity.Position = new Vector3(ReferringEntity.Position.X, ReferringEntity.Position.Y, MathHelper.SmoothStep(ReferringEntity.Position.Z, _cameraTargetPosition.Z, 0.2f));
                }
                if (Math.Abs(_cameraTargetPosition.Y - ReferringEntity.Position.Y) > float.Epsilon)
                {
                    ReferringEntity.Position = new Vector3(ReferringEntity.Position.X, MathHelper.SmoothStep(ReferringEntity.Position.Y, _cameraTargetPosition.Y, 0.2f), ReferringEntity.Position.Z);
                }
            }
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:51,代码来源:PlayerControllerComponent.cs

示例2: Update

        public override void Update(GameTime time)
        {
            base.Update(time);
            if (State != UiState.Active) return;

            _remainingLifeTime -= time.GetSeconds();
            if (_remainingLifeTime <= 0.0f) Hide();
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:8,代码来源:NotificationItem.cs

示例3: Update

        public void Update(GameTime gameTime)
        {
            if (IsFinished) return;
            _elapsedTime += gameTime.GetSeconds();

            if (_elapsedTime >= _transitionTime)
            {
                IsFinished = true;
                _elapsedTime = _transitionTime;
            }
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:11,代码来源:BlendTransition.cs

示例4: Update

        /// <summary>
        /// Updates Animator.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            if (CurrentAnimation == null) return;

            CurrentAnimation.Update(gameTime.GetSeconds());
            if (CurrentAnimation.IsFinished)
            {
                if (CurrentAnimation.IsLoop)
                {
                    CurrentAnimation.Start();
                }
                else
                {
                    AnimationFinished?.Invoke(_currentAnimationName, CurrentAnimation.PlayReversed);

                    string newAnimation;
                    if (_transitions.TryGetValue(_currentAnimationName, out newAnimation))
                    {
                        SetAnimation(newAnimation);
                    }
                    else
                    {
                        CurrentAnimation = null;
                        AnimatorFinished?.Invoke();
                    }
                }
            }
        }
开发者ID:nilllzz,项目名称:Pokemon3D,代码行数:31,代码来源:Animator.cs


注:本文中的Microsoft.Xna.Framework.GameTime.GetSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。