Example #1
0
 private void OnInteractPress(object source, EventArgs args)
 {
     if (Movement != MovementType.Paused)
     {
         PlayerInteracted?.Invoke(this, EventArgs.Empty);
     }
 }
Example #2
0
 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);
        }
    }
Example #4
0
 protected virtual void OnPlayerInteracted()
 {
     PlayerInteracted?.Invoke(this, EventArgs.Empty);
 }