public bool Interact(Transform _transform, Vector3 position)
        {
            if (playerMove.isGhost)
            {
                return(false);
            }

            //attempt to trigger the things in range we clicked on
            if (PlayerManager.LocalPlayerScript.IsInReach(position))
            {
                //check the actual transform for an input trigger and if there is non, check the parent
                InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>();
                if (inputTrigger)
                {
                    if (objectBehaviour.visibleState)
                    {
                        inputTrigger.Trigger(position);

                        //FIXME currently input controller only uses the first InputTrigger found on an object
                        /////// some objects have more then 1 input trigger, like players for example
                        /////// below is a solution that should be removed when InputController is refactored
                        /////// to support multiple InputTriggers on the target object
                        if (inputTrigger.gameObject.layer == 8)
                        {
                            //This is a player. Attempt to use the player based inputTrigger
                            P2PInteractions playerInteractions = inputTrigger.gameObject.GetComponent <P2PInteractions>();
                            if (playerInteractions != null)
                            {
                                playerInteractions.Trigger(position);
                            }
                        }
                        return(true);
                    }
                    //Allow interact with cupboards we are inside of!
                    ClosetControl cCtrl = inputTrigger.GetComponent <ClosetControl>();
                    if (cCtrl && cCtrl.transform.position == PlayerManager.LocalPlayerScript.transform.position)
                    {
                        inputTrigger.Trigger(position);
                        return(true);
                    }
                    return(false);
                }
            }
            //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything
            return(InteractHands());
        }
        public bool Interact(Transform _transform, Vector3 position)
        {
            if (playerMove.isGhost)
            {
                return(false);
            }
            ;

            //attempt to trigger the things in range we clicked on
            if (PlayerManager.LocalPlayerScript.IsInReach(position))
            {
                //check the actual transform for an input trigger and if there is non, check the parent
                InputTrigger inputTrigger = _transform.GetComponent <InputTrigger>();
                if (inputTrigger)
                {
                    if (objectBehaviour.visibleState)
                    {
                        inputTrigger.Trigger(position);
                        return(true);
                    }
                    return(false);
                }
                inputTrigger = _transform.parent.GetComponent <InputTrigger>();
                if (inputTrigger)
                {
                    if (objectBehaviour.visibleState)
                    {
                        inputTrigger.Trigger();
                        return(true);
                    }
                    //Allow interact with cupboards we are inside of!
                    ClosetControl cCtrl = inputTrigger.GetComponent <ClosetControl>();
                    if (cCtrl && cCtrl.transform.position == PlayerManager.LocalPlayerScript.transform.position)
                    {
                        inputTrigger.Trigger();
                        return(true);
                    }
                    return(false);
                }
            }
            //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything
            return(InteractHands());
        }
    public void Init(ClosetControl closetCtrl)
    {
        closetControl = closetCtrl;

        if (!PlayerManager.LocalPlayerScript.playerNetworkActions.isGhost)
        {
            // TODO: Change this stuff to the proper settings once re-entering corpse becomes a feature.
            Camera2DFollow.followControl.target  = closetControl.transform;
            Camera2DFollow.followControl.damping = 0.2f;
        }

        if (!closetControl)
        {
            //this is not a closet. Could be a coffin or disposals
            Logger.LogWarning("No closet found for ClosetPlayerHandler!" + " maybe it's time to update this component? (see the todo's)", Category.Containers);
            Destroy(this);
        }
        else
        {
            monitor = true;
        }
    }
    public void CmdToggleCupboard(GameObject cupbObj)
    {
        ClosetControl closetControl = cupbObj.GetComponent <ClosetControl>();

        closetControl.ServerToggleCupboard();
    }
Exemple #5
0
 private void Awake()
 {
     closetControl = GetComponent <ClosetControl>();
 }
Exemple #6
0
 private void Awake()
 {
     registerTile = GetComponent <RegisterTile>();
     closet       = GetComponent <ClosetControl>();
 }
    /// <summary>
    /// Checks for the various interactions that can occur and delegates to the appropriate trigger classes.
    /// Note that only one interaction is allowed to occur in this method - the first time any trigger returns true
    /// (indicating that interaction logic has occurred), the method returns.
    /// </summary>
    /// <param name="_transform">transform to check the interaction of</param>
    /// <param name="position">position the interaction is taking place</param>
    /// <param name="isDrag">is this during (but not at the very start of) a drag?</param>
    /// <returns>true iff an interaction occurred</returns>
    public bool Interact(Transform _transform, Vector3 position, bool isDrag)
    {
        if (playerMove.isGhost)
        {
            return(false);
        }

        //attempt to trigger the things in range we clicked on
        var localPlayer = PlayerManager.LocalPlayerScript;

        if (localPlayer.IsInReach(Camera.main.ScreenToWorldPoint(Input.mousePosition)) || localPlayer.IsHidden)
        {
            //Check for melee triggers first. If a melee interaction occurs, stop checking for any further interactions
            MeleeTrigger meleeTrigger = _transform.GetComponentInParent <MeleeTrigger>();
            //no melee action happens due to a drag
            if (meleeTrigger != null && !isDrag)
            {
                if (meleeTrigger.MeleeInteract(gameObject, UIManager.Hands.CurrentSlot.eventName))
                {
                    return(true);
                }
            }

            //check the actual transform for an input trigger and if there is non, check the parent
            InputTrigger inputTrigger = _transform.GetComponentInParent <InputTrigger>();
            if (inputTrigger)
            {
                if (objectBehaviour.visibleState)
                {
                    bool interacted = false;
                    if (isDrag)
                    {
                        interacted = inputTrigger.TriggerDrag(position);
                    }
                    else
                    {
                        interacted = inputTrigger.Trigger(position);
                    }

                    if (interacted)
                    {
                        return(true);
                    }

                    //FIXME currently input controller only uses the first InputTrigger found on an object
                    /////// some objects have more then 1 input trigger, like players for example
                    /////// below is a solution that should be removed when InputController is refactored
                    /////// to support multiple InputTriggers on the target object
                    if (inputTrigger.gameObject.layer == 8)
                    {
                        //This is a player. Attempt to use the player based inputTrigger
                        P2PInteractions playerInteractions = inputTrigger.gameObject.GetComponent <P2PInteractions>();
                        if (playerInteractions != null)
                        {
                            if (isDrag)
                            {
                                interacted = playerInteractions.TriggerDrag(position);
                            }
                            else
                            {
                                interacted = playerInteractions.Trigger(position);
                            }
                        }
                    }
                    if (interacted)
                    {
                        return(true);
                    }
                }
                //Allow interact with cupboards we are inside of!
                ClosetControl closet = inputTrigger.GetComponent <ClosetControl>();
                //no closet interaction happens when dragging
                if (closet && Camera2DFollow.followControl.target == closet.transform && !isDrag)
                {
                    if (inputTrigger.Trigger(position))
                    {
                        return(true);
                    }
                }
                return(false);
            }
        }

        //if we are holding onto an item like a gun attempt to shoot it if we were not in range to trigger anything
        return(InteractHands(isDrag));
    }