Ejemplo n.º 1
0
        public GameObject InstantiateOwnedObject(string prefabName)
        {
            GameObject localObj = InstantiateLocally(prefabName);

            if (localObj != null)
            {
                RaiseInstantiateEventHandler(localObj);
                int[] whiteListIDs = new int[1];
                whiteListIDs[0] = PhotonNetwork.player.ID;
                //UnityEngine.Debug.Log("About to raise restriction event.");
                OwnableObject ownershipManager = localObj.GetComponent <OwnableObject>();
                ownershipManager.SetRestrictions(true, whiteListIDs);
                RaiseObjectOwnershipRestrictionEventHandler(localObj, true, whiteListIDs);
            }
            return(localObj);
        }
Ejemplo n.º 2
0
        private void HandleSyncObjectOwnershipRestriction(ExitGames.Client.Photon.Hashtable eventData)
        {
            string objectName = (string)eventData[(byte)0];
            int    viewID     = (int)eventData[(byte)1];
            bool   restricted = (bool)eventData[(byte)2];

            int[] ownableIDs      = (int[])eventData[(byte)3];
            int   serverTimeStamp = (int)eventData[(byte)4];

            //UnityEngine.Debug.Log("restricted = " + ((restricted) ? "true" : "false"));

            GameObject[] objs = GameObject.FindObjectsOfType <GameObject>();
            GameObject   go   = null;

            foreach (GameObject obj in objs)
            {
                if (obj.name.Equals(objectName))
                {
                    PhotonView pv = obj.GetComponent <PhotonView>();
                    if (pv == null)
                    {
                        continue;
                    }
                    else if (pv.viewID == viewID)
                    {
                        go = obj;
                        break;
                    }
                }
            }

            if (go != null)
            {
                OwnableObject ownershipManager = go.GetComponent <OwnableObject>();
                ownershipManager.SetRestrictions(restricted, ownableIDs);
            }
        }
Ejemplo n.º 3
0
        private void HandleSyncSceneEvent(ExitGames.Client.Photon.Hashtable eventData)
        {
            int targetPlayerID = (int)eventData[(byte)0];

            if (PhotonNetwork.player.ID == targetPlayerID)
            {
                string  prefabName = (string)eventData[(byte)1];
                Vector3 position   = Vector3.zero;
                Vector3 scale      = Vector3.one;
                if (eventData.ContainsKey((byte)2))
                {
                    position = (Vector3)eventData[(byte)2];
                }
                Quaternion rotation = Quaternion.identity;
                if (eventData.ContainsKey((byte)3))
                {
                    rotation = (Quaternion)eventData[(byte)3];
                }
                scale = (Vector3)eventData[(byte)4];

                int[] viewIDs = (int[])eventData[(byte)5];
                if (eventData.ContainsKey((byte)6))
                {
                    uint currentLevelPrefix = (uint)eventData[(byte)6];
                }

                int serverTimeStamp = (int)eventData[(byte)7];
                int instantiationID = (int)eventData[(byte)8];

                GameObject go = InstantiateLocally(prefabName, viewIDs, position, rotation, scale);

                OwnableObject ownershipManager      = go.GetComponent <OwnableObject>();
                bool          isOwnershipRestricted = (bool)eventData[(byte)9];
                int[]         whiteListIDs          = (int[])eventData[(byte)10];
                ownershipManager.SetRestrictions(isOwnershipRestricted, whiteListIDs);
            }
        }