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); } } }
public override void Update(GameTime time) { base.Update(time); if (State != UiState.Active) return; _remainingLifeTime -= time.GetSeconds(); if (_remainingLifeTime <= 0.0f) Hide(); }
public void Update(GameTime gameTime) { if (IsFinished) return; _elapsedTime += gameTime.GetSeconds(); if (_elapsedTime >= _transitionTime) { IsFinished = true; _elapsedTime = _transitionTime; } }
/// <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(); } } } }