private void CheckClick()
    {
        bool ctrlClick = KeyboardInputManager.IsControlPressed();

        if (!ctrlClick)
        {
            //change the facingDirection of player on click
            ChangeDirection();

            //if we found nothing at all to click on try to use whats in our hands (might be shooting at someone in space)
            if (!RayHitInteract(false) && !EventSystem.current.IsPointerOverGameObject())
            {
                InteractHands(false);
            }
        }
        else
        {
            Renderer hitRenderer;
            if (RayHit(false, out hitRenderer))
            {
                if (!hitRenderer)
                {
                    return;
                }
                hitRenderer.transform.SendMessageUpwards("OnCtrlClick", SendMessageOptions.DontRequireReceiver);
            }
        }
    }
示例#2
0
    private bool CheckClick()
    {
        ChangeDirection();
        //currently there is nothing for ghosts to interact with, they only can change facing
        if (PlayerManager.LocalPlayerScript.IsGhost)
        {
            return(false);
        }

        bool ctrlClick = KeyboardInputManager.IsControlPressed();

        if (!ctrlClick)
        {
            var handApplyTargets =
                MouseUtils.GetOrderedObjectsUnderMouse(layerMask);

            //go through the stack of objects and call any interaction components we find
            foreach (GameObject applyTarget in handApplyTargets)
            {
                if (CheckHandApply(applyTarget))
                {
                    return(true);
                }
            }
        }

        return(false);
    }
    /// <summary>
    /// Checks for a click within the interaction framework v2. Until everything is moved over to V2,
    /// this will have to be used alongside the old one.
    /// </summary>
    private bool CheckClickV2()
    {
        //currently there is nothing for ghosts to interact with, they only can change facing
        if (PlayerManager.LocalPlayerScript.IsGhost)
        {
            return(false);
        }

        bool ctrlClick = KeyboardInputManager.IsControlPressed();

        if (!ctrlClick)
        {
            var handApplyTargets =
                MouseUtils.GetOrderedObjectsUnderMouse(layerMask, go => go.GetComponent <RegisterTile>() != null)
                //get the root gameobject of the dropped-on sprite renderer
                .Select(sr => sr.GetComponentInParent <RegisterTile>().gameObject)
                //only want distinct game objects even if we hit multiple renderers on one object.
                .Distinct();
            //object in hand
            var handObj = UIManager.Hands.CurrentSlot.Item;

            //go through the stack of objects and call any drop components we find
            foreach (GameObject applyTarget in handApplyTargets)
            {
                HandApply info = new HandApply(PlayerManager.LocalPlayer, handObj, applyTarget.gameObject);
                //call the used object's handapply interaction methods if it has any, for each object we are applying to
                //if handobj is null, then its an empty hand apply so we only need to check the receiving object
                if (handObj != null)
                {
                    foreach (IInteractable <HandApply> handApply in handObj.GetComponents <IInteractable <HandApply> >())
                    {
                        var result = handApply.Interact(info);
                        if (result.SomethingHappened)
                        {
                            //we're done checking, something happened
                            return(true);
                        }
                    }
                }

                //call the hand apply interaction methods on the target object if it has any
                foreach (IInteractable <HandApply> handApply in applyTarget.GetComponents <IInteractable <HandApply> >())
                {
                    var result = handApply.Interact(info);
                    if (result.SomethingHappened)
                    {
                        //something happened, done checking
                        return(true);
                    }
                }
            }
        }

        return(false);
    }
示例#4
0
    public override 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;
        }

        if (CommonInput.GetMouseButtonDown(0))
        {
            if (ClicksFromBlobHud())
            {
                return;
            }

            //check ctrl+click for dragging
            if (KeyboardInputManager.IsControlPressed())
            {
                //Place strong blob / reflective if strong blob already
                blobPlayer.CmdTryPlaceStrongReflective(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt());
                return;
            }

            if (KeyboardInputManager.IsShiftPressed())
            {
                //like above, send shift-click request, then do nothing else.
                Inspect();
                return;
            }

            if (KeyboardInputManager.IsAltPressed())
            {
                //Remove blob
                blobPlayer.CmdRemoveBlob(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt());
                return;
            }

            blobPlayer.CmdTryPlaceBlobOrAttack(Camera.main.ScreenToWorldPoint(CommonInput.mousePosition).RoundToInt());
        }
        else
        {
            CheckHover();
        }
    }
示例#5
0
        public override 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;
            }

            if (CommonInput.GetMouseButtonDown(0))
            {
                if (KeyboardInputManager.IsControlPressed() && KeyboardInputManager.IsShiftPressed())
                {
                    CheckForInteractions(AiActivate.ClickTypes.CtrlShiftClick);
                    return;
                }

                //check ctrl+click for dragging
                if (KeyboardInputManager.IsControlPressed())
                {
                    CheckForInteractions(AiActivate.ClickTypes.CtrlClick);
                    return;
                }

                if (KeyboardInputManager.IsShiftPressed())
                {
                    //like above, send shift-click request, then do nothing else.
                    //Inspect();
                    CheckForInteractions(AiActivate.ClickTypes.ShiftClick);
                    return;
                }

                if (KeyboardInputManager.IsAltPressed())
                {
                    CheckForInteractions(AiActivate.ClickTypes.AltClick);
                    return;
                }

                CheckForInteractions(AiActivate.ClickTypes.NormalClick);
            }
            else
            {
                CheckHover();
            }
        }
    //note - bool is now returned to indicate the CheckClickV2 should be skipped if an interacton occurs in
    //this version of the method.
    private bool CheckClick()
    {
        //currently there is nothing for ghosts to interact with, they only can change facing
        if (PlayerManager.LocalPlayerScript.IsGhost)
        {
            ChangeDirection();
            return(false);
        }

        bool ctrlClick = KeyboardInputManager.IsControlPressed();

        if (!ctrlClick)
        {
            //change the facingDirection of player on click
            ChangeDirection();

            if (RayHitInteract(false))
            {
                return(true);
            }

            //if we found nothing at all to click on try to use whats in our hands (might be shooting at someone in space)
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                return(InteractHands(false));
            }

            return(false);
        }
        else
        {
            Renderer hitRenderer;
            if (RayHit(false, out hitRenderer))
            {
                if (!hitRenderer)
                {
                    return(true);
                }
                hitRenderer.transform.SendMessageUpwards("OnCtrlClick", SendMessageOptions.DontRequireReceiver);
                return(true);
            }
            //we always return true for a ctrl click in the current system - this will not always be the case
            return(true);
        }
    }
    private bool CheckClick()
    {
        ChangeDirection();
        //currently there is nothing for ghosts to interact with, they only can change facing
        if (PlayerManager.LocalPlayerScript.IsGhost)
        {
            return(false);
        }

        bool ctrlClick = KeyboardInputManager.IsControlPressed();

        if (!ctrlClick)
        {
            var handApplyTargets =
                MouseUtils.GetOrderedObjectsUnderMouse();

            //go through the stack of objects and call any interaction components we find
            foreach (GameObject applyTarget in handApplyTargets)
            {
                if (CheckHandApply(applyTarget))
                {
                    return(true);
                }
            }
            //check empty space positional hand apply
            var posHandApply = PositionalHandApply.ByLocalPlayer(null);
            if (posHandApply.HandObject != null)
            {
                var handAppliables = posHandApply.HandObject.GetComponents <IBaseInteractable <PositionalHandApply> >()
                                     .Where(c => c != null && (c as MonoBehaviour).enabled);
                if (InteractionUtils.ClientCheckAndTrigger(handAppliables, posHandApply) != null)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
示例#8
0
        private void OnClickItem(PointerEventData eventData, RightClickRadialButton button)
        {
            var subItems = Items[button.Index]?.SubMenus;

            if (subItems == null)
            {
                return;
            }

            // Copern: Not a preferable method of doing this but the original RightClickMenuItem wasn't really
            // designed for this. Also need to switch this to use keybinds.
            if (KeyboardInputManager.IsShiftPressed())
            {
                DoAction(examineOption);
            }
            else if (KeyboardInputManager.IsControlPressed())
            {
                DoAction(pullOption);
            }
            else
            {
                DoAction(pickUpOption);
            }

            void DoAction(RightClickOption option)
            {
                foreach (var item in subItems)
                {
                    if (item.Label != option.label)
                    {
                        continue;
                    }
                    item.Action();
                    this.SetActive(option.keepMenuOpen);
                    return;
                }
            }
        }
示例#9
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();
        }
    }