public void RpcLetGo(int humanoidId, bool isLeft)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                PhotonLog("RpcLetGo");
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    PhotonLogWarning("Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = isLeft ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            if (handTarget != null)
            {
                HandInteraction.LocalLetGo(handTarget);
            }
        }
Exemplo n.º 2
0
        [ClientRpc] // @ remote client
        public void RpcClientChangeNamedAvatar(int humanoidId, string avatarPrefabName)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(netId.Value + ": RpcChangeAvatar " + humanoidId + "to: " + avatarPrefabName);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            GameObject remoteAvatar = (GameObject)Resources.Load(avatarPrefabName);

            if (remoteAvatar == null)
            {
                if (debug <= HumanoidNetworking.Debug.Error)
                {
                    Debug.LogError("Could not load remote avatar " + avatarPrefabName + ". Is it located in a Resources folder?");
                }
                return;
            }
            humanoid.LocalChangeAvatar(remoteAvatar);
        }
        public void RpcGrab(int humanoidId, int objViewID, bool isLeft, bool rangeCheck)
        {
            PhotonView objView = PhotonView.Find(objViewID);
            GameObject obj     = objView.gameObject;

            if (debug <= HumanoidNetworking.Debug.Info)
            {
                PhotonLog("RpcGrab " + obj);
            }

            if (obj == null)
            {
                return;
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    PhotonLogWarning("Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = isLeft ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            if (handTarget != null)
            {
                HandInteraction.LocalGrab(handTarget, obj, rangeCheck);
            }
        }
        private void ReceiveAvatarPose(PhotonStream reader)
        {
            this.reader = reader;

            int humanoidsCount = ReceiveInt();

            for (int i = 0; i < humanoidsCount; i++)
            {
                int nwId = ReceiveInt();
#if hPHOTON2
                if (nwId != photonView.ViewID)
                {
                    return;
                }
#else
                if (nwId != photonView.viewID)
                {
                    return;
                }
#endif
                int humanoidId = ReceiveInt();

                HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);
                if (humanoid == null)
                {
                    if (debug <= HumanoidNetworking.Debug.Warning)
                    {
                        Debug.LogWarning(nwId + ": Could not find humanoid: " + humanoidId);
                    }
                    return;
                }

                this.ReceiveAvatarPose(humanoid, ref lastPoseTime, ref lastReceiveTime, ref lastReceivedPosition);
            }
        }
        public void RpcDestroyHumanoid(int nwId, int humanoidId)
        {
            HumanoidControl remoteHumanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (remoteHumanoid == null)
            {
                // Unknown remote humanoid
                return;
            }

            if (remoteHumanoid.gameObject != null)
            {
                Destroy(remoteHumanoid.gameObject);
            }
        }
Exemplo n.º 6
0
        private void RpcClientDestroyHumanoid(int nwId, int humanoidId)
        {
            if (isLocalPlayer && !createLocalRemotes)
            {
                return;
            }

            HumanoidControl remoteHumanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (remoteHumanoid == null)
            {
                // Unknown remote humanoid
                return;
            }

            if (remoteHumanoid.gameObject != null)
            {
                Destroy(remoteHumanoid.gameObject);
            }
        }
Exemplo n.º 7
0
        public void ReceiveAvatarPose(NetworkMessage msg, int humanoidId)
        {
            if (isLocalPlayer && !createLocalRemotes)
            {
                return;
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            reader = msg.reader;
            this.ReceiveAvatarPose(humanoid, ref lastPoseTime, ref lastReceiveTime, ref lastReceivedPosition);
        }
Exemplo n.º 8
0
        [ClientRpc] // @ remote client
        public void RpcClientLetGo(int nwId, int humanoidId, bool leftHanded)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(netId + ": RpcLetGo " + humanoidId);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = leftHanded ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            HandInteraction.LocalLetGo(handTarget);
        }
Exemplo n.º 9
0
        [ClientRpc] // @ remote client
        public void RpcClientGrab(int nwId, int humanoidId, GameObject obj, bool leftHanded, bool rangeCheck)
        {
            if (debug <= HumanoidNetworking.Debug.Info)
            {
                Debug.Log(nwId + ": RpcGrab " + obj);
            }

            HumanoidControl humanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (humanoid == null)
            {
                if (debug <= HumanoidNetworking.Debug.Warning)
                {
                    Debug.LogWarning(netId.Value + ": Could not find humanoid: " + humanoidId);
                }
                return;
            }

            HandTarget handTarget = leftHanded ? humanoid.leftHandTarget : humanoid.rightHandTarget;

            HandInteraction.LocalGrab(handTarget, obj, rangeCheck);
        }
        public void RpcStartHumanoid(
            int nwId, int humanoidId,
            string name, string avatarPrefabName,
            Vector3 position, Quaternion rotation,
            bool physics)
        {
#if hPHOTON2
            if (nwId != photonView.ViewID)
#else
            if (nwId != photonView.viewID)
#endif
            { return; }

            HumanoidControl remoteHumanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);
            if (remoteHumanoid != null)
            {
                // This remote humanoid already exists
                return;
            }

            humanoids.Add(HumanoidNetworking.StartHumanoid(nwId, humanoidId, name, avatarPrefabName, position, rotation, physics));
        }
Exemplo n.º 11
0
        [ClientRpc] // @ remote client
        private void RpcClientStartHumanoid(
            int nwId,
            int humanoidId,
            string name,
            string avatarPrefabName,
            Vector3 position, Quaternion rotation,
            bool physics
            )
        {
            if (isLocalPlayer && !createLocalRemotes)
            {
                return;
            }

            HumanoidControl remoteHumanoid = HumanoidNetworking.FindRemoteHumanoid(humanoids, humanoidId);

            if (remoteHumanoid != null)
            {
                // This remote humanoid already exists
                return;
            }

            humanoids.Add(HumanoidNetworking.StartHumanoid(nwId, humanoidId, name, avatarPrefabName, position, rotation, physics));
        }