コード例 #1
0
    public void CmdStopPulling(GameObject obj)
    {
        if (!isPulling)
        {
            return;
        }

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

        pulled.RpcToggleCnt(true);
        //Cache value for new players
        pulled.custNetActiveState = true;
        if (pulled != null)
        {
            //			//this triggers currentPos syncvar hook to make sure registertile is been completed on all clients
            //			pulled.currentPos = pulled.transform.position;

            IPlayerSync pS = gameObject.GetComponent <IPlayerSync>();
            pS.PullObjectID = NetworkInstanceId.Invalid;
            pulled.pulledBy = null;
        }
        var netTransform = obj.GetComponent <CustomNetTransform>();

        if (netTransform != null)
        {
            netTransform.SetPosition(obj.transform.localPosition);
        }
    }
コード例 #2
0
 private void Start()
 {
     playerSprites = gameObject.GetComponent <PlayerSprites>();
     playerSync    = GetComponent <IPlayerSync>();
     pushPull      = GetComponent <PushPull>();
     registerTile  = GetComponent <RegisterTile>();
     pna           = gameObject.GetComponent <PlayerNetworkActions>();
 }
コード例 #3
0
        public void CmdSetPositionFromReset(GameObject fromObj, GameObject otherPlayer, Vector3 setPos)
        {
            if (fromObj.GetComponent <IPlayerSync>() == null)  //Validation
            {
                return;
            }
            IPlayerSync otherPlayerSync = otherPlayer.GetComponent <IPlayerSync>();

            otherPlayerSync.SetPosition(setPos);
        }
コード例 #4
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;
        }
    }
コード例 #5
0
 /// <summary>
 /// Sets the player sync interface
 /// </summary>
 /// <param name="playerSync"></param>
 public void SetPlayerSync(IPlayerSync playerSync)
 {
     this.playerSyncMono = playerSync;
 }
コード例 #6
0
 /// <summary>
 /// Sets the player sync interface
 /// </summary>
 /// <param name="playerSync"></param>
 public void SetPlayerSync(IPlayerSync playerSync)
 {
     this.playerSyncMono = playerSync;
 }