private void OnInteractPress(object source, EventArgs args) { if (Movement != MovementType.Paused) { PlayerInteracted?.Invoke(this, EventArgs.Empty); } }
private void Update() { if (Input.GetKeyDown(KeyCode.Space) && interactionAvailableHint.activeSelf) { PlayerInteracted?.Invoke(); soundSource.Play(); } }
void Update() { #region moving if (UnityEngine.Input.GetKey(KeyCode.W)) { MoveClicked?.Invoke(Vector2.up); } else if (UnityEngine.Input.GetKey(KeyCode.A)) { MoveClicked?.Invoke(Vector2.left); } else if (UnityEngine.Input.GetKey(KeyCode.S)) { MoveClicked?.Invoke(Vector2.down); } else if (UnityEngine.Input.GetKey(KeyCode.D)) { MoveClicked?.Invoke(Vector2.right); } #endregion #region mouse click if (!EventSystem.current.IsPointerOverGameObject()) { if (UnityEngine.Input.GetMouseButtonDown(0)) { PlayerShoot?.Invoke(); } if (UnityEngine.Input.GetKeyDown(KeyCode.E)) { PlayerInteracted?.Invoke(); } } #endregion #region mouse move float mouseMove = UnityEngine.Input.GetAxis("Mouse X"); if (mouseMove != 0) { PlayerMovedMouse?.Invoke(mouseMove); } //Vector3 currentMousePos = UnityEngine.Input.mousePosition; //if (currentMousePos.x != mousePos.x) //{ // float difference = currentMousePos.x - mousePos.x; // PlayerMovedMouse?.Invoke(difference); //} //mousePos = currentMousePos; #endregion if (UnityEngine.Input.GetKeyDown(KeyCode.Tab)) { inventoryOpened = !inventoryOpened; InventoryModeChangedTo?.Invoke(inventoryOpened); } if (UnityEngine.Input.GetKeyDown(KeyCode.P)) { ingamePresetMenuOpened = !ingamePresetMenuOpened; IngamePreserMenuClick?.Invoke(ingamePresetMenuOpened); } }
protected virtual void OnPlayerInteracted() { PlayerInteracted?.Invoke(this, EventArgs.Empty); }