public void StartListning() { while (true) { ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key.Equals(ConsoleKey.A)) { OnAPressed?.Invoke(this, new EventArgs()); } else if (key.Key.Equals(ConsoleKey.D)) { OnDPressed?.Invoke(this, new EventArgs()); } else if (key.Key.Equals(ConsoleKey.Spacebar)) { OnSpacePressed?.Invoke(this, new EventArgs()); } else { } } }
private void NotifyAPressed() { OnAPressed?.Invoke(); SayToLog("A pressed."); }
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); } }