本文整理汇总了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);
}
}
}
示例2: Update
public override void Update(GameTime time)
{
base.Update(time);
if (State != UiState.Active) return;
_remainingLifeTime -= time.GetSeconds();
if (_remainingLifeTime <= 0.0f) Hide();
}
示例3: Update
public void Update(GameTime gameTime)
{
if (IsFinished) return;
_elapsedTime += gameTime.GetSeconds();
if (_elapsedTime >= _transitionTime)
{
IsFinished = true;
_elapsedTime = _transitionTime;
}
}
示例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();
}
}
}
}