Example #1
0
 private void CheckMouseInput()
 {
     if (UIManager.IsMouseInteractionDisabled)
     {
         //still allow tooltips
         CheckHover();
         return;
     }
     if (CommonInput.GetMouseButtonDown(0))
     {
         if (!CheckAltClick())
         {
             if (!CheckThrow())
             {
                 CheckClick();
             }
         }
     }
     else if (CommonInput.GetMouseButton(0))
     {
         //mouse being held down / dragged
         CheckDrag();
     }
     else
     {
         CheckHover();
     }
 }
    private void CheckMouseInput()
    {
        if (UIManager.IsMouseInteractionDisabled)
        {
            //still allow tooltips
            CheckHover();
            return;
        }

        if (!canDrag && CommonInput.GetMouseButtonUp(0))
        {
            //reset candrag on buttonup
            canDrag = true;
        }
        if (CommonInput.GetMouseButtonDown(0))
        {
            var clicked = CheckAltClick();
            if (!clicked)
            {
                clicked = CheckThrow();
            }
            if (!clicked)
            {
                clicked = CheckClick();
            }
            if (!clicked)
            {
                clicked = CheckClickV2();
            }

            if (clicked)
            {
                //wait until mouseup to allow drag interaction again
                canDrag = false;
            }
        }
        else if (CommonInput.GetMouseButton(0))
        {
            //mouse being held down / dragged
            if (!CheckDrag() && canDrag)
            {
                CheckDragV2();
            }
        }
        else
        {
            CheckHover();
        }
    }
Example #3
0
 private void CheckMouseInput()
 {
     if (CommonInput.GetMouseButtonDown(0))
     {
         if (!CheckAltClick())
         {
             if (!CheckThrow())
             {
                 CheckClick();
             }
         }
     }
     else if (CommonInput.GetMouseButton(0))
     {
         //mouse being held down / dragged
         CheckDrag();
     }
     else
     {
         CheckHover();
     }
 }
Example #4
0
    private void CheckMouseInput()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            //don't do any game world interactions if we are over the UI
            return;
        }

        if (UIManager.IsMouseInteractionDisabled)
        {
            //still allow tooltips
            CheckHover();
            return;
        }

        //do we have a loaded gun
        var loadedGun = GetLoadedGunInActiveHand();

        if (CommonInput.GetMouseButtonDown(0))
        {
            //check ctrl+click for dragging
            if (KeyboardInputManager.IsControlPressed())
            {
                //even if we didn't drag anything, nothing else should happen
                CheckInitiatePull();

                return;
            }

            //check the alt click and throw, which doesn't have any special logic
            if (CheckAltClick())
            {
                return;
            }
            if (CheckThrow())
            {
                return;
            }

            if (loadedGun != null)
            {
                //if we are on harm intent with loaded gun,
                //don't do anything else, just shoot (trigger the AimApply).
                if (UIManager.CurrentIntent == Intent.Harm)
                {
                    CheckAimApply(MouseButtonState.PRESS);
                }
                else
                {
                    //proceed to normal click interaction
                    CheckClickInteractions(true);
                }
            }
            else
            {
                //we don't have a loaded gun
                //Are we over something draggable?
                var draggable = GetDraggable();
                if (draggable != null)
                {
                    //We are over a draggable. We need to wait to see if the user
                    //tries to drag the object or lifts the mouse.
                    potentialDraggable = draggable;
                    dragStartOffset    = MouseWorldPosition - potentialDraggable.transform.position;
                    clickDuration      = 0;
                }
                else
                {
                    //no possibility of dragging something, proceed to normal click logic
                    CheckClickInteractions(true);
                }
            }
        }
        else if (CommonInput.GetMouseButton(0))
        {
            //mouse button being held down.
            //increment the time since they initially clicked the mouse
            clickDuration += Time.deltaTime;

            //If we are possibly dragging and have exceeded the drag distance, initiate the drag
            if (potentialDraggable != null)
            {
                var currentOffset = MouseWorldPosition - potentialDraggable.transform.position;
                if (((Vector2)currentOffset - dragStartOffset).magnitude > MouseDragDeadzone)
                {
                    potentialDraggable.BeginDrag();
                    potentialDraggable = null;
                }
            }

            //continue to trigger the aim apply if it was initially triggered
            CheckAimApply(MouseButtonState.HOLD);
        }
        else if (CommonInput.GetMouseButtonUp(0))
        {
            //mouse button is lifted.
            //If we were waiting for mouseup to trigger a click, trigger it if we're still within
            //the duration threshold
            if (potentialDraggable != null)
            {
                if (clickDuration < MaxClickDuration)
                {
                    //we are lifting the mouse, so AimApply should not be performed but other
                    //clicks can.
                    CheckClickInteractions(false);
                }

                clickDuration      = 0;
                potentialDraggable = null;
            }

            //no more triggering of the current aim apply
            triggeredAimApply = null;
            secondsSinceLastAimApplyTrigger = 0;
        }
        else
        {
            CheckHover();
        }
    }