public InputResult OnKeyDown(UserInputKey keyCode, ModifierKeys modifiers) { if (!IsHandlerEnabled || modifiers != ModifierKeys.None) { return(InputResult.Continue); } InputResult inputResult; float cameraHeight; // Mouse scroll requires more effort to scroll as much as regular keys, // so we add a multiplier to keep it more consistent with other keys const int mouseScrollMultiplier = 3; if (_cameraHeightKeys.CameraUpKeys.Contains(keyCode)) { if (keyCode == UserInputKey.MouseScrollDown || keyCode == UserInputKey.MouseScrollUp) { cameraHeight = _gameValueService.GetZCameraPosition(); cameraHeight += CameraMovementOffset * mouseScrollMultiplier; _gameValueService.SetZCameraPosition(cameraHeight); inputResult = InputResult.StopProcessingEvents | InputResult.HideFromOtherApplications; } else { _isCameraMovingUp = true; inputResult = InputResult.StopProcessingEvents | InputResult.HideFromOtherApplications; } } else if (_cameraHeightKeys.CameraDownKeys.Contains(keyCode)) { if (keyCode == UserInputKey.MouseScrollDown || keyCode == UserInputKey.MouseScrollUp) { cameraHeight = _gameValueService.GetZCameraPosition(); cameraHeight -= CameraMovementOffset * mouseScrollMultiplier; _gameValueService.SetZCameraPosition(cameraHeight); inputResult = InputResult.StopProcessingEvents | InputResult.HideFromOtherApplications; } else { _isCameraMovingDown = true; inputResult = InputResult.StopProcessingEvents | InputResult.HideFromOtherApplications; } } else { inputResult = InputResult.Continue; } if (!_actionLoopService.IsLoopingAction && (_isCameraMovingDown || _isCameraMovingUp)) { _actionLoopService.StartLoopingAction(MoveCamera); } return(inputResult); }
public InputResult OnKeyDown(UserInputKey keyCode, ModifierKeys modifiers) { if (!IsHandlerEnabled || modifiers != ModifierKeys.None) { return(InputResult.Continue); } InputResult inputResult; if (_cameraMovementKeys.CameraForwardKeys.Contains(keyCode)) { _isCameraMovingUp = true; inputResult = InputResult.HideFromOtherApplications | InputResult.StopProcessingEvents; } else if (_cameraMovementKeys.CameraBackKeys.Contains(keyCode)) { _isCameraMovingBack = true; inputResult = InputResult.HideFromOtherApplications | InputResult.StopProcessingEvents; } else if (_cameraMovementKeys.CameraLeftKeys.Contains(keyCode)) { _isCameraMovingLeft = true; inputResult = InputResult.HideFromOtherApplications | InputResult.StopProcessingEvents; } else if (_cameraMovementKeys.CameraRightKeys.Contains(keyCode)) { _isCameraMovingRight = true; inputResult = InputResult.HideFromOtherApplications | InputResult.StopProcessingEvents; } else { inputResult = InputResult.Continue; } if (!_actionLoopService.IsLoopingAction && (_isCameraMovingUp || _isCameraMovingBack || _isCameraMovingLeft || _isCameraMovingRight)) { _isCameraMovingInAnyDirection = true; _actionLoopService.StartLoopingAction(MoveCamera); } return(inputResult); }