private void Update() { if (Input.GetKeyDown(KeyCode.LeftArrow)) { OnMove?.Invoke(Vector2Int.left); } if (Input.GetKeyDown(KeyCode.RightArrow)) { OnMove?.Invoke(Vector2Int.right); } if (Input.GetKeyDown(KeyCode.UpArrow)) { OnMove?.Invoke(Vector2Int.up); } if (Input.GetKeyDown(KeyCode.DownArrow)) { OnMove?.Invoke(Vector2Int.down); } if (Input.GetKeyDown(KeyCode.R)) { OnRestart?.Invoke(); } if (Input.GetKeyDown(KeyCode.Escape)) { OnEscape?.Invoke(); } }
private IEnumerator Escape() { OnEscape?.Invoke(); yield return(new WaitForSeconds(Fade.FadeLenght)); LoadMenu(); }
public void Update() { pather.Update(); motorAnimator.Update(); if (isPaniced) { Debug.Log(Math.Abs((transform.position - entrance).magnitude)); } if (isPaniced && Math.Abs((transform.position - entrance).magnitude) < (0.2f + finalOffset.magnitude)) { OnEscape?.Invoke(); } }
protected override void KeyPress(VirtualKeys key, bool hold) { //Do not react if the current menu is not open. if (!isOpen) { return; } long now = GameTime.Ticks; switch (key) { case VirtualKeys.Return: if (!hold) { //Check the index or we will get into trouble if no item does exist if (cursor >= 0 && Items.Count > cursor) { Items[cursor].OnActivate?.Invoke(); PlaySound(sndSelect); } } break; case VirtualKeys.Escape: if (!hold) { //I dont think closing is a good default behavior for pressing escape. For now lets just invoke the event. //this.Close(); OnEscape?.Invoke(this); PlaySound(sndEscape); } break; default: if (CurrentItem is InputReceiver rec) { rec.KeyPressed(key); } break; } }
IEnumerator ListenToInput() { while (true) { yield return(null); if (input.GetKeyDown(settings.ToggleConsole) && !anyKeyLastFrame) { OnToggleVisibility?.Invoke(); } anyKeyLastFrame = input.AnyKey; if (!console.Enabled) { continue; } if (input.GetKeyDown(settings.Submit) || input.GetKeyDown(settings.Submit2)) { OnSubmit(); } else if (input.GetKeyDown(settings.HintUp)) { OnMoveUp?.Invoke(); } else if (input.GetKeyDown(settings.HintDown)) { OnMoveDown?.Invoke(); } else if (input.GetKeyDown(settings.CloseHint)) { OnEscape?.Invoke(); } } }
private void Update() { if (Input.GetKey(KeyCode.A)) { OnPlayerHorizontal?.Invoke(-1); isMovingHor = true; } else if (Input.GetKey(KeyCode.D)) { OnPlayerHorizontal?.Invoke(1); isMovingHor = true; } //DUDAS SOBRE OPTIMIZACIÓN else if (isMovingHor && !Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D)) { OnPlayerHorizontal?.Invoke(0); isMovingHor = false; } if (Input.GetKey(KeyCode.S)) { OnPlayerVertical?.Invoke(-1); isMovingVer = true; } else if (Input.GetKey(KeyCode.W)) { OnPlayerVertical?.Invoke(1); isMovingVer = true; } else if (isMovingVer && !Input.GetKey(KeyCode.S) && !Input.GetKey(KeyCode.W)) { OnPlayerVertical?.Invoke(0); isMovingVer = false; } if (Input.GetMouseButtonDown(0)) { OnPlayerAttack?.Invoke(); } if (Input.GetKeyDown(KeyCode.E)) { OnPlayerFire?.Invoke(); } if (Input.GetMouseButton(1)) { OnPlayerBlock?.Invoke(); } else if (Input.GetMouseButtonUp(1)) { OnPlayerStopBlocking?.Invoke(); } if (Input.GetKeyDown(KeyCode.Space)) { OnPlayerJump?.Invoke(); } if (Input.GetKeyDown(KeyCode.Escape)) { OnEscape?.Invoke(); } }
private void OnInputEscape(InputAction.CallbackContext context) { //Debug.Log("Escape"); OnEscape?.Invoke(); }