public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("Inventory")) { HandleInventory(); } else if (@event.IsActionPressed("Back")) { HandleBack(); } }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("ui_do_less")) { OnButtonPressed(); } }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("main_save")) { GetNode <EditorControls>("..").SaveDiagram(); } }
public override void _UnhandledKeyInput(InputEventKey @event) { if (@event.IsActionPressed("ui_cancel", true)) { OnCloseButtonPressed(); return; } }
public override void _UnhandledKeyInput(InputEventKey key) { if (Pressed && key.IsActionPressed("main_remove")) { OnItemSelected(0); Pressed = false; ReleaseFocus(); GetPopup().Visible = false; } }
public override void _UnhandledKeyInput(InputEventKey @event) { // I don't like iterating over every single possible action every time - surely there's a nicer way to do this? foreach (string mapping in ActionMapping.AllMappings) { if (@event.IsActionPressed(mapping, true) && _playerMappingQueue.Count < _queueSize) { _playerMappingQueue.Add(new InputAction(mapping)); return; } } }
/// <summary> /// Change the weapon of the current character on key pressed /// </summary> /// <param name="inputEvent">Key pressed by the user</param> public override void _Input(InputEvent inputEvent) { base._Input(inputEvent); if (inputEvent is InputEventKey && this.currentCharacter != null) { InputEventKey keyEvent = inputEvent as InputEventKey; if (keyEvent.IsActionPressed("rifle")) { currentCharacter.SelectedWeapon = Character.SelectableWeapon.Rifle; } else if (keyEvent.IsActionPressed("rocket_launcher")) { currentCharacter.SelectedWeapon = Character.SelectableWeapon.Bazooka; } else if (keyEvent.IsActionPressed("grenade")) { currentCharacter.SelectedWeapon = Character.SelectableWeapon.Grenade; } } }
private void UsePotion(InputEventKey _keyboardInput) { if (_keyboardInput.IsActionPressed("ui_select")) { if (player.Inventory.IsItemInIventory(potion)) { player.Stats.CurrentHealth += potion.GetRestoreAmount(player); player.Stats.CallForUpdateOfPlayerCurrentHP(); player.Inventory.RemoveItem(potion); } else { console.PrintMessageToConsole("Player doesn't have any potions!"); } } }
private Vector2 GetKeyboardMoveToPosition(InputEventKey _keyboardInput) { // Returns a vector2 position which the player will move based upon directions pressed on keyboard. // The keyboard input will return a simple direction which will be added to the players current grid position Vector2 moveToPosition = new Vector2(); // Cardnial Directions if (_keyboardInput.IsAction("ui_up")) { moveToPosition = player.GridPosition + new Vector2(0, -1); } if (_keyboardInput.IsAction("ui_down")) { moveToPosition = player.GridPosition + new Vector2(0, 1); } if (_keyboardInput.IsAction("ui_right")) { moveToPosition = player.GridPosition + new Vector2(1, 0); } if (_keyboardInput.IsAction("ui_left")) { moveToPosition = player.GridPosition + new Vector2(-1, 0); } // Diagnial Directions if (_keyboardInput.IsActionPressed("ui_up") && _keyboardInput.IsActionPressed("ui_right")) { moveToPosition = player.GridPosition + new Vector2(1, -1); } if (_keyboardInput.IsActionPressed("ui_up") && _keyboardInput.IsActionPressed("ui_left")) { moveToPosition = player.GridPosition + new Vector2(-1, -1); } if (_keyboardInput.IsActionPressed("ui_down") && _keyboardInput.IsActionPressed("ui_right")) { moveToPosition = player.GridPosition + new Vector2(1, 1); } if (_keyboardInput.IsActionPressed("ui_left") && _keyboardInput.IsActionPressed("ui_right")) { moveToPosition = player.GridPosition + new Vector2(-1, 1); } return(moveToPosition); }