/// <summary> /// Checks to see if a key was pressed. /// </summary> /// <returns>Key Press, null if nothing was pressed.</returns> public RLKeyPress GetKeyPress() { RLKeyPress kp = keyPress; keyPress = null; return(kp); }
private void gameWindow_KeyDown(object sender, KeyboardKeyEventArgs e) { KeyboardState keyState = Keyboard.GetState(); if (e.Key == Key.NumLock) { numLock = !numLock; } else if (e.Key == Key.CapsLock) { capsLock = !capsLock; } else if (e.Key == Key.ScrollLock) { scrollLock = !scrollLock; } //Check modifier keys (OpenTK changes) shift = (keyState.IsKeyDown(Key.LShift) || keyState.IsKeyDown(Key.RShift)); ctrl = (keyState.IsKeyDown(Key.LControl) || keyState.IsKeyDown(Key.RControl)); alt = (keyState.IsKeyDown(Key.LAlt) || keyState.IsKeyDown(Key.RAlt)); RLKeyPress newKeyPress = new RLKeyPress((RLKey)e.Key, alt, shift, ctrl, e.IsRepeat, numLock, capsLock, scrollLock); if (keyPress != newKeyPress) { keyPress = newKeyPress; } }
public void Input(RLNET.RLKeyPress keypress) { GameFlowComponent turn = Parent.GetComponent <GameFlowComponent> (); switch (keypress.Key) { case RLKey.W: Parent.GetComponent <MovementComponent> ().Move(Direction.North); turn.TurnComplete(); break; case RLKey.S: Parent.GetComponent <MovementComponent> ().Move(Direction.South); turn.TurnComplete(); break; case RLKey.A: Parent.GetComponent <MovementComponent> ().Move(Direction.West); turn.TurnComplete(); break; case RLKey.D: Parent.GetComponent <MovementComponent> ().Move(Direction.East); turn.TurnComplete(); break; case RLKey.Z: Parent.GetComponent <VisionComponent> ().Range = 2; Util.Messages.AddMessage("The darkness closes in on you.", Message.MessageType.Debuff); turn.TurnComplete(); break; case RLKey.X: Parent.GetComponent <VisionComponent> ().Range = 4; Util.Messages.AddMessage("Your vision clears.", Message.MessageType.Buff); turn.TurnComplete(); break; case RLKey.C: Parent.GetComponent <VisionComponent> ().Range = 8; Util.Messages.AddMessage("The way forward becomes clear.", Message.MessageType.Buff); turn.TurnComplete(); break; } }
private void gameWindow_KeyDown(object sender, OpenTK.Input.KeyboardKeyEventArgs e) { if (e.Key == OpenTK.Input.Key.NumLock) { numLock = !numLock; } else if (e.Key == OpenTK.Input.Key.CapsLock) { capsLock = !capsLock; } else if (e.Key == OpenTK.Input.Key.ScrollLock) { scrollLock = !scrollLock; } RLKeyPress newKeyPress = new RLKeyPress((RLKey)e.Key, e.Alt, e.Shift, e.Control, e.IsRepeat, numLock, capsLock, scrollLock); if (keyPress != newKeyPress) { keyPress = newKeyPress; } }