Ejemplo n.º 1
0
    void InputControl()
    {
        if (Input.GetMouseButtonDown(0) && controlsEnable && !GamePlayUI.Instance.WhetherOnButton())
        {
            Vector3      mouseWorldPos = mainCamera.ScreenToWorldPoint(Input.mousePosition);
            RaycastHit2D hit           = Physics2D.Raycast(mouseWorldPos, Vector2.zero, 100, clickableLayerMask);
            RaycastHit2D hitNotAllow   = Physics2D.Raycast(mouseWorldPos, Vector2.zero, 100, notAllowLayerMask);

            Debug.Log("Pointer down at " + mouseWorldPos);

            if (hit.collider != null && hitNotAllow.collider == null)
            {
                if (currentActiveHand == Hand.Right)
                {
                    rightHand.InteractAt(new Vector2(mouseWorldPos.x, mouseWorldPos.y));
                }
                else if (leftHandObj.activeSelf && currentActiveHand == Hand.Left)
                {
                    leftHand.InteractAt(new Vector2(mouseWorldPos.x, mouseWorldPos.y));
                }
            }
        }
        else if (Input.GetMouseButtonUp(0))
        {
            if (currentActiveHand == Hand.Right)
            {
                rightHand.EndInteract();
            }
            else if (leftHandObj.activeSelf && currentActiveHand == Hand.Left)
            {
                rightHand.EndInteract();
            }
        }
    }