private void Input_OnKey(SInputEvent e) { // Commands which are only allowed when game is currently running and not paused. if (State != GameState.Paused) { // Fire primary player weapon. if ((e.KeyPressed(EKeyId.eKI_Space) || e.KeyPressed(EKeyId.eKI_XI_A)) && _player.Exists) { _player.Fire(); } } if ((State != GameState.Finished) && (e.KeyPressed(EKeyId.eKI_Escape) || e.KeyPressed(EKeyId.eKI_XI_Start))) { if (_gameOverTime == DateTime.MinValue) { State = State == GameState.Paused ? GameState.Running : GameState.Paused; if (State == GameState.Paused) { Hud.CurrentHud.ShowGamePauseDialog(); } else { Hud.CurrentHud.HideGamePauseDialog(); } } } }
/// <summary> /// Called by Canvas. Do not call directly. /// </summary> public void OnKey(SInputEvent e) { if (Items.Count > 0) { if (e.KeyPressed(EKeyId.eKI_Down)) { _idx = Math.Min(Items.Count - 1, _idx + 1); } if (e.KeyPressed(EKeyId.eKI_Up)) { _idx = Math.Max(0, _idx - 1); } } else { _idx = -1; } if (e.keyName.key.Length == 1) { var key = e.keyName.key.ToUpper(); var chosen = Items.FirstOrDefault(x => x.ToString().ToUpper().StartsWith(key)); if (chosen != null) { _idx = Items.IndexOf(chosen); } } SelectedItem = _idx < 0 ? null : Items [_idx]; }
public override void OnInputKey(SInputEvent arg) { if (_earthquake == null) { return; } if (arg.KeyDown(EKeyId.eKI_W)) { _earthquake.Position += Vec3.Right * 4f * FrameTime.Delta; } if (arg.KeyDown(EKeyId.eKI_S)) { _earthquake.Position += -Vec3.Right * 4f * FrameTime.Delta; } if (arg.KeyDown(EKeyId.eKI_A)) { if (_earthquake.MinAmplitude > 0.5f) { _earthquake.MinAmplitude -= 0.5f; _earthquake.MaxAmplitude -= 0.5f; } } if (arg.KeyDown(EKeyId.eKI_D)) { _earthquake.MinAmplitude += 0.5f; _earthquake.MaxAmplitude += 0.5f; } if (arg.KeyDown(EKeyId.eKI_Q)) { _earthquake.Radius -= 0.1f; _earthquake.Radius = MathExtensions.Clamp(_earthquake.Radius, 0.25f, _earthquake.Radius); } if (arg.KeyDown(EKeyId.eKI_E)) { _earthquake.Radius += 0.1f; } if (arg.KeyPressed(EKeyId.eKI_R)) { _earthquake.RandomOffset += 1f; } if (arg.KeyPressed(EKeyId.eKI_F)) { _earthquake.RandomOffset -= 1f; _earthquake.RandomOffset = MathExtensions.Clamp(_earthquake.RandomOffset, 0f, _earthquake.RandomOffset); } if (arg.KeyPressed(EKeyId.eKI_V)) { _earthquake.Visualize = !_earthquake.Visualize; } }
public override void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_Space) || e.KeyPressed(EKeyId.eKI_Enter) || e.KeyPressed(EKeyId.eKI_XI_A)) { if (OnPressed != null) { OnPressed(); } } }
private void Input_OnKey(SInputEvent arg) { if (arg.KeyPressed(EKeyId.eKI_Tab) && _levelManager.Maps.Count != 0) { _levelManager.LoadNextLevel(); } if (arg.KeyPressed(EKeyId.eKI_Escape)) { Env.Console.ExecuteString("quit"); } }
void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_Escape) && !Env.IsSandbox) { Shutdown(); } // Show/Hide FPS Label on F5. if (e.KeyPressed(EKeyId.eKI_F5)) { _fpsText.Active = !_fpsText.Active; } }
void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_Escape) && !Engine.IsSandbox) { Engine.Console.ExecuteString("quit"); } // Show/Hide FPS Label on F5. if (e.KeyPressed(EKeyId.eKI_F5)) { _fpsText.Active = !_fpsText.Active; } }
/// <summary> /// Called by Canvas. Do not call directly. /// </summary> public override void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_Space)) { IsChecked = !IsChecked; } }
private void Input_OnKey(SInputEvent arg) { if (arg.KeyPressed(EKeyId.eKI_Space)) { Spawn(); } }
void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_Escape) && !Engine.IsSandbox) { Engine.Console.ExecuteString("quit"); } }
void OnKey(SInputEvent e) { if (e.KeyPressed(EKeyId.eKI_E)) { CreateBall(); } if (e.KeyPressed(EKeyId.eKI_V)) { AddImpulse(); } if (e.KeyPressed(EKeyId.eKI_T)) { balls.ToList().ForEach(x => x.Destroy()); balls.Clear(); } }
private void Input_OnKey(SInputEvent arg) { _currentHandler?.OnInputKey(arg); if (arg.KeyPressed(_uiToggleKey)) { _currentHandler.ToggleUI(); } }
/// <summary> /// Called by framework. Do not call directly. /// </summary> public void OnKey(SInputEvent e) { if (!Active) { return; } if ((e.KeyPressed(EKeyId.eKI_Tab) && Input.ShiftDown) || e.KeyPressed(EKeyId.eKI_XI_DPadUp) || e.KeyPressed(EKeyId.eKI_XI_DPadLeft)) { FocusPreviousComponent(); } else if (e.KeyPressed(EKeyId.eKI_Tab) || e.KeyPressed(EKeyId.eKI_XI_DPadDown) || e.KeyPressed(EKeyId.eKI_XI_DPadRight)) { FocusNextComponent(); } else if (CurrentFocus != null) { CurrentFocus.InvokeOnKey(e); } }
/// <summary> /// Called by Canvas. Do not call directly. /// </summary> public override void OnKey(SInputEvent e) { if (!_submitDesired) { if (e.KeyPressed(EKeyId.eKI_Enter)) { SetCursor(true); _submitDesired = true; } return; } if (e.KeyPressed(EKeyId.eKI_Escape)) { _text.Content = _contentBackup; PositionContent(true); SetCursor(false); _submitDesired = false; } else if (e.KeyPressed(EKeyId.eKI_Home)) { _cursorIndex = 0; SetCursor(true); PositionContent(); } else if (e.KeyPressed(EKeyId.eKI_End)) { _cursorIndex = _text.Content.Length; SetCursor(true); PositionContent(); } else if (e.KeyPressed(EKeyId.eKI_Delete)) { if (_cursorIndex < _text.Content.Length) { _text.Content = _text.Content.Substring(0, _cursorIndex) + _text.Content.Substring(_cursorIndex + 1); } SetCursor(true); } else if (e.KeyPressed(EKeyId.eKI_Enter) || e.KeyPressed(EKeyId.eKI_XI_A)) { if (TrySubmit()) { SetCursor(false); _contentBackup = _text.Content; } } else if (e.KeyPressed(EKeyId.eKI_Backspace)) { if (_cursorIndex > 0) { _text.Content = _text.Content.Substring(0, _cursorIndex - 1) + _text.Content.Substring(_cursorIndex); SetCursor(true); _cursorIndex--; } PositionContent(true); } else if (e.KeyPressed(EKeyId.eKI_Left)) { _cursorIndex = Math.Max(0, _cursorIndex - 1); SetCursor(true); PositionContent(); } else if (e.KeyPressed(EKeyId.eKI_Right)) { _cursorIndex = Math.Min(_text.Content.Length, _cursorIndex + 1); SetCursor(true); PositionContent(); } else if (e.state == EInputState.eIS_Pressed) { _text.Content = _text.Content.Insert(_cursorIndex, e.keyName.key); _cursorIndex += e.keyName.key.Length; SetCursor(true); PositionContent(true); } }