// Update is called once per frame public void Update() { _movement.x = _movementForwardInput.y; _movement.z = _movementForwardInput.x; _rotation.y = _movementRotateInput.x; _rotation.z = _movementRotateInput.y; OnMovementKeyPressed?.Invoke(_movement, _rotation); }
private void Update() { if (CheckKey(KeyCode.W)) { OnWPressed?.Invoke(this, EventArgs.Empty); KeyEventArgs args = new KeyEventArgs(KeyCode.W); OnKeyPressed?.Invoke(this, args); OnMovementKeyPressed?.Invoke(this, args); } if (CheckKey(KeyCode.A)) { OnAPressed?.Invoke(this, EventArgs.Empty); KeyEventArgs args = new KeyEventArgs(KeyCode.A); OnKeyPressed?.Invoke(this, args); OnMovementKeyPressed?.Invoke(this, args); } if (CheckKey(KeyCode.S)) { OnSPressed?.Invoke(this, EventArgs.Empty); KeyEventArgs args = new KeyEventArgs(KeyCode.S); OnKeyPressed?.Invoke(this, args); OnMovementKeyPressed?.Invoke(this, args); } if (CheckKey(KeyCode.D)) { OnDPressed?.Invoke(this, EventArgs.Empty); KeyEventArgs args = new KeyEventArgs(KeyCode.D); OnKeyPressed?.Invoke(this, args); OnMovementKeyPressed?.Invoke(this, args); } if (CheckKey(KeyCode.Space)) { OnSpacePressed?.Invoke(this, EventArgs.Empty); KeyEventArgs args = new KeyEventArgs(KeyCode.Space); OnKeyPressed?.Invoke(this, args); } RunKey(KeyCode.G); RunKey(KeyCode.H); RunKey(KeyCode.Q); RunKey(KeyCode.Escape); var scrollDelta = Input.GetAxis("Mouse ScrollWheel"); if (scrollDelta != 0.0F) { ScrollEventArgs args; if (scrollDelta > 0.0F) { args = new ScrollEventArgs(true); OnScrollUp?.Invoke(this, EventArgs.Empty); } else { args = new ScrollEventArgs(false); OnScrollDown?.Invoke(this, EventArgs.Empty); } OnScroll?.Invoke(this, args); } if (CheckMouseSingle(MouseButton.LEFT)) { ClickEventArgs args = new ClickEventArgs(MouseButton.LEFT, Input.mousePosition); OnMouseClick?.Invoke(this, args); OnLeftMouseClick?.Invoke(this, args); } if (CheckMouseSingle(MouseButton.RIGHT)) { ClickEventArgs args = new ClickEventArgs(MouseButton.RIGHT, Input.mousePosition); OnMouseClick?.Invoke(this, args); OnRightMouseClick?.Invoke(this, args); } }