Esempio n. 1
0
    public void CmdPullObject(GameObject obj)
    {
        if (isPulling)
        {
            GameObject cObj = gameObject.GetComponent <IPlayerSync>().PullingObject;
            cObj.GetComponent <PushPull>().pulledBy = null;
            gameObject.GetComponent <IPlayerSync>().PullObjectID = NetworkInstanceId.Invalid;
        }

        PushPull pulled = obj.GetComponent <PushPull>();

        //Stop CNT as the transform of the pulled obj is now handled by PlayerSync
        pulled.RpcToggleCnt(false);
        //Cache value for new players
        pulled.custNetActiveState = false;
        //check if the object you want to pull is another player
        if (pulled.isPlayer)
        {
            IPlayerSync playerS = obj.GetComponent <IPlayerSync>();
            //Anything that the other player is pulling should be stopped
            if (playerS.PullingObject != null)
            {
                PlayerNetworkActions otherPNA = obj.GetComponent <PlayerNetworkActions>();
                otherPNA.CmdStopOtherPulling(playerS.PullingObject);
            }
        }
        //Other player is pulling object, send stop on that player
        if (pulled.pulledBy != null)
        {
            if (pulled.pulledBy != gameObject)
            {
                pulled.GetComponent <PlayerNetworkActions>().CmdStopPulling(obj);
            }
        }

        if (pulled != null)
        {
            IPlayerSync pS = GetComponent <IPlayerSync>();
            pS.PullObjectID = pulled.netId;
            isPulling       = true;
        }
    }
Esempio n. 2
0
    public void CmdPullObject(GameObject obj)
    {
        if (isPulling)
        {
            GameObject cObj = gameObject.GetComponent <PlayerSync>().pullingObject;
            cObj.GetComponent <PushPull>().pulledBy             = null;
            gameObject.GetComponent <PlayerSync>().pullObjectID = NetworkInstanceId.Invalid;
        }

        PushPull pulled = obj.GetComponent <PushPull>();

        //check if the object you want to pull is another player
        if (pulled.isPlayer)
        {
            PlayerSync playerS = obj.GetComponent <PlayerSync>();
            //Anything that the other player is pulling should be stopped
            if (playerS.pullingObject != null)
            {
                PlayerNetworkActions otherPNA = obj.GetComponent <PlayerNetworkActions>();
                otherPNA.CmdStopOtherPulling(playerS.pullingObject);
            }
        }
        //Other player is pulling object, send stop on that player
        if (pulled.pulledBy != null)
        {
            if (pulled.pulledBy != gameObject)
            {
                pulled.GetComponent <PlayerNetworkActions>().CmdStopPulling(obj);
            }
        }



        if (pulled != null)
        {
            PlayerSync pS = GetComponent <PlayerSync>();
            pS.pullObjectID = pulled.netId;
            isPulling       = true;
        }
    }