public void OnPhotonPlayerConnected(PhotonPlayer player)
        {
#endif
            List <HumanoidControl> humanoids = HumanoidNetworking.FindLocalHumanoids();
            if (humanoids.Count <= 0)
            {
                return;
            }

            foreach (HumanoidControl humanoid in humanoids)
            {
                if (debug <= HumanoidNetworking.Debug.Info)
                {
                    Debug.Log(humanoid.nwId + ": (Re)Send StartHumanoid " + humanoid.humanoidId);
                }

                // Notify new player about my humanoid
#if hPHOTON2
                photonView.RPC("RpcStartHumanoid", RpcTarget.Others, humanoid.nwId, humanoid.humanoidId, humanoid.gameObject.name, humanoid.remoteAvatar.name, humanoid.transform.position, humanoid.transform.rotation, humanoid.physics);
#else
                photonView.RPC("RpcStartHumanoid", PhotonTargets.Others, humanoid.nwId, humanoid.humanoidId, humanoid.gameObject.name, humanoid.remoteAvatar.name, humanoid.transform.position, humanoid.transform.rotation, humanoid.physics);
#endif
                if (humanoid.leftHandTarget.grabbedObject != null)
                {
                    humanoid.humanoidNetworking.Grab(humanoid.leftHandTarget, humanoid.leftHandTarget.grabbedObject, false);
                }
                if (humanoid.rightHandTarget.grabbedObject != null)
                {
                    humanoid.humanoidNetworking.Grab(humanoid.rightHandTarget, humanoid.rightHandTarget.grabbedObject, false);
                }
            }
        }
        public void OnPhotonInstantiate(PhotonMessageInfo info)
        {
#if hPHOTON2
            if (photonView.IsMine)
            {
#else
            if (photonView.isMine)
            {
#endif
                isLocal = true;
                name    = "HumanoidPun(Local)";

                humanoids = HumanoidNetworking.FindLocalHumanoids();
                if (debug <= HumanoidNetworking.Debug.Info)
                {
                    PhotonLog("Found " + humanoids.Count + " Humanoids");
                }

                if (humanoids.Count <= 0)
                {
                    return;
                }

                foreach (HumanoidControl humanoid in humanoids)
                {
#if hPHOTON2
                    humanoid.nwId = photonView.ViewID;
#else
                    humanoid.nwId = photonView.viewID;
#endif
                    humanoid.humanoidNetworking = this;

                    if (debug <= HumanoidNetworking.Debug.Info)
                    {
                        Debug.Log(humanoid.nwId + ": Send Start Humanoid " + humanoid.humanoidId);
                    }

#if hPHOTON2
                    photonView.RPC("RpcStartHumanoid", RpcTarget.Others, humanoid.nwId, humanoid.humanoidId, humanoid.gameObject.name, humanoid.remoteAvatar.name, humanoid.transform.position, humanoid.transform.rotation, humanoid.physics);
#else
                    photonView.RPC("RpcStartHumanoid", PhotonTargets.Others, humanoid.nwId, humanoid.humanoidId, humanoid.gameObject.name, humanoid.remoteAvatar.name, humanoid.transform.position, humanoid.transform.rotation, humanoid.physics);
#endif
                }

                NetworkingSpawner spawner = FindObjectOfType <NetworkingSpawner>();
                if (spawner != null)
                {
                    spawner.OnNetworkingStarted();
                }
            }
        }
Пример #3
0
        public override void OnStartLocalPlayer()
        {
            isLocal = true;
            name    = "HumanoidUnet(Local)";

            humanoids = HumanoidNetworking.FindLocalHumanoids();
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log((int)netId.Value + ": Found " + humanoids.Count + " Humanoids");
            }

            if (humanoids.Count <= 0)
            {
                CmdServerStartNoHumanoid((int)netId.Value);
                return;
            }

            foreach (HumanoidControl humanoid in humanoids)
            {
                humanoid.nwId = (int)netId.Value;
                humanoid.humanoidNetworking = this;

                if (debug <= HumanoidNetworking.Debug.Info)
                {
                    Debug.Log(humanoid.nwId + ": Send Start Humanoid " + humanoid.humanoidId);
                }

                CmdServerStartHumanoid(
                    humanoid.nwId,
                    humanoid.humanoidId,
                    humanoid.gameObject.name,
                    humanoid.remoteAvatar.name,
                    humanoid.transform.position, humanoid.transform.rotation,
                    humanoid.physics);
            }
            NetworkingSpawner spawner = FindObjectOfType <NetworkingSpawner>();

            if (spawner != null)
            {
                spawner.OnNetworkingStarted();
            }
        }