Exemple #1
0
    void Update()
    {
        SScore_       = score_ + Score_;
        s1.text       = score_.ToString();
        S1.text       = Score_.ToString();
        SS1.text      = SScore_.ToString();
        LookWin1.text = P1Win.ToString();
        LookWin2.text = P2Win.ToString();

        if (S_L.Judgment != 1 && !wait.activeSelf)
        {
            nameAndScore.SetActive(true);
        }

        if (Sc["score_"].ToString() != s1.text)
        {
            Sc.Remove("score_");
            PhotonNetwork.LocalPlayer.SetCustomProperties(Sc, null);
            Sc.Add("score_", score_);
        }
        if (Sc["Score_"].ToString() != S1.text)
        {
            Sc.Remove("Score_");
            PhotonNetwork.LocalPlayer.SetCustomProperties(Sc, null);
            Sc.Add("Score_", Score_);
        }
    }
 /// <summary>
 /// Method which is called when class is contructed, and deletes references to other user's controllers
 /// </summary>
 private void Start()
 {
     if (PV.IsMine)
     {
         //subscribe the mouse senstivity method to settings update event
         GameEvents.current.onSettingsUpdate += updateMouse;
         //Equip the first item available
         EquipItem(0);
         //Remove the material entry in the hashmap if there is one
         if (customProperties.ContainsKey("app"))
         {
             customProperties.Remove("app");
         }
         //Determine the material that a player should be rendered as
         if (PhotonNetwork.IsMasterClient)
         {
             customProperties.Add("app", 1);
             PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties);
         }
         else
         {
             customProperties.Add("app", 2);
             PhotonNetwork.LocalPlayer.SetCustomProperties(customProperties);
         }
     }
     else
     {
         //destroy cameras and rigidbodies if they are not assigned to the local user
         Destroy(GetComponentInChildren <Camera>().gameObject);
         Destroy(rb);
     }
 }
Exemple #3
0
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        if (stream.IsWriting)
        {
            // If new Data, send
            if (ChangedTeam || ChangedReady || ChangedDisplayName)
            {
                ChangedTeam        = false;
                ChangedReady       = false;
                ChangedDisplayName = false;
                stream.SendNext(TeamNum);
                stream.SendNext(IsReady);
                stream.SendNext(PhotonNetwork.LocalPlayer.ActorNumber);
                stream.SendNext(DisplayName);
            }
        }
        else
        {
            // When packets arrive, change
            int    ChangedNum         = (int)stream.ReceiveNext();
            bool   ChangedReady       = (bool)stream.ReceiveNext();
            int    ChangedActor       = (int)stream.ReceiveNext();
            string ChangedDisplayName = (string)stream.ReceiveNext();

            Player ChangedPlayer = null;
            foreach (Player P in RoomPlayerList)
            {
                if (P.ActorNumber == ChangedActor)
                {
                    ChangedPlayer = P;
                    break;
                }
            }

            if (ChangedPlayer != null)
            {
                ExitGames.Client.Photon.Hashtable hash = ChangedPlayer.CustomProperties;
                hash.Remove("Team");
                hash.Remove("ReadyToPlay");
                hash.Remove("DisplayName");
                hash.Add("Team", ChangedNum);
                hash.Add("ReadyToPlay", ChangedReady);
                hash.Add("DisplayName", ChangedDisplayName);
                ChangedPlayer.SetCustomProperties(hash);
                print("Changed Player (Team / ActorNum / DisplayName): (" + ChangedNum + " / " + ChangedActor + " / " + ChangedDisplayName + ")");
            }
        }
    }
Exemple #4
0
    public void Update()
    {
        if (NetwordLauncher.mapSelect != 0 && MapID == 0 && PhotonNetwork.IsMasterClient)
        {
            o = NetwordLauncher.mapSelect - 1;
            transform.GetChild(o).gameObject.SetActive(true);
            if (!lookMap.ContainsKey("map"))
            {
                lookMap.Add("map", o);
                PhotonNetwork.LocalPlayer.SetCustomProperties(lookMap, null);
            }
            else
            {
                lookMap.Remove("map");
                lookMap.Add("map", o);
                PhotonNetwork.LocalPlayer.SetCustomProperties(lookMap, null);
            }
            //for (int i = 0; i < transform.childCount; i++)
            //{
            //    transform.GetChild(i).gameObject.SetActive(false);
            //}
        }

        if (!PhotonNetwork.IsMasterClient)
        {
            foreach (Player player in PhotonNetwork.PlayerList)
            {
                if (player.IsMasterClient)
                {
                    o = (int)player.CustomProperties["map"];
                }
            }
            transform.GetChild(o).gameObject.SetActive(true);
        }
    }
 //PhotonNetwork function for handling when PlayerLeaves the room
 //need to inherit from MonoBehaviourPunCallbacks to use this
 public override void OnPlayerLeftRoom(Player otherPlayer)
 {
     if (otherPlayer == PhotonNetwork.LocalPlayer && photonView.IsMine)
     {
         PhotonNetwork.RemoveRPCs(PhotonNetwork.LocalPlayer);
         _myCustomProperty.Remove("PlayerIndexNumber");
     }
 }
Exemple #6
0
 public void RemoveFromCustomProperties(ExitGames.Client.Photon.Hashtable removeProps)
 {
     ExitGames.Client.Photon.Hashtable revHashTable = this.customProperties;
     foreach (System.Collections.DictionaryEntry props in removeProps)
     {
         revHashTable.Remove(props.Key);
     }
     this.SetCustomProperties(revHashTable);
 }
    private IEnumerator UpdatePing()
    {
        yield return(new WaitForSeconds(1));

        playerProps.Remove("Ping");
        playerProps.Add("Ping", PhotonNetwork.GetPing());
        PhotonNetwork.player.SetCustomProperties(playerProps);
        StartCoroutine("UpdatePing");
    }
 public static void UpdateProps <T>(Player player, string key, T value)
 {
     ExitGames.Client.Photon.Hashtable props = player.CustomProperties;
     if (props.ContainsKey(key))
     {
         props.Remove(key);
     }
     props.Add(key, value);
     player.SetCustomProperties(props);
 }
 public override void OnPlayerLeftRoom(Player otherPlayer)
 {
     base.OnPlayerLeftRoom(otherPlayer);
     if (PhotonNetwork.IsMasterClient)
     {
         ExitGames.Client.Photon.Hashtable properties = PhotonNetwork.CurrentRoom.CustomProperties;
         properties.Remove(otherPlayer.UserId);
         PhotonNetwork.CurrentRoom.SetCustomProperties(properties);
     }
 }
Exemple #10
0
 public void UpdateTimer()
 {
     if (PhotonNetwork.IsMasterClient)
     {
         CurrentTime -= Time.deltaTime;
         ExitGames.Client.Photon.Hashtable auxiliaryCustomPropertie = PhotonNetwork.CurrentRoom.CustomProperties;
         auxiliaryCustomPropertie.Remove("Timer");
         auxiliaryCustomPropertie.Add("Timer", CurrentTime);
         PhotonNetwork.CurrentRoom.SetCustomProperties(auxiliaryCustomPropertie);
     }
 }
Exemple #11
0
    //--------------------------------------------------------------
    /// Used to add to the cheese counter of this character.
    //--------------------------------------------------------------
    public void addOneToCheeseCount()
    {
        Debug.Log("cheese collected");
        ExitGames.Client.Photon.Hashtable h = PhotonNetwork.player.customProperties;
        int newScore = int.Parse(h["CheeseCount"].ToString());

        h.Remove("CheeseCount");
        newScore++;
        h.Add("CheeseCount", newScore.ToString());
        PhotonNetwork.player.SetCustomProperties(h);
    }
Exemple #12
0
    private void UpdateUnits()
    {
        hexPlayer.lockBoard();
        Hashtable hash = PhotonNetwork.player.CustomProperties;

        if (hash.ContainsKey(UNITS_KEY))
        {
            hash.Remove(UNITS_KEY);
        }
        hash.Add(UNITS_KEY, UnitInfoToByteArray(hexPlayer.currentUnits));
        PhotonNetwork.player.SetCustomProperties(hash);
    }
 public void SetDisplayName(string name)
 {
     DisplayName = name;
     Debug.Log("Set DisplayName " + DisplayName);
     ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable();
     hash = PhotonNetwork.LocalPlayer.CustomProperties;
     hash.Remove("DisplayName");
     hash.Add("DisplayName", DisplayName);
     PhotonNetwork.LocalPlayer.SetCustomProperties(hash);
     Debug.Log("Set DisplayName (Hash)" + (string)PhotonNetwork.LocalPlayer.CustomProperties["DisplayName"]);
     //SetDisplayNameBool = true;
 }
Exemple #14
0
    public void ChangeToQueue()
    {
        ExitGames.Client.Photon.Hashtable hash = new ExitGames.Client.Photon.Hashtable();
        hash = PhotonNetwork.LocalPlayer.CustomProperties;
        int Team = (int)hash["Team"];

        if (Team != -1)
        {
            hash.Remove("Team");
            hash.Add("Team", -1);

            PhotonNetwork.LocalPlayer.CustomProperties = hash;
        }
        bool IsReady = (bool)PhotonNetwork.LocalPlayer.CustomProperties["ReadyToPlay"];

        if (IsReady)
        {
            hash.Remove("ReadyToPlay");
            hash.Add("ReadyToPlay", false);

            PhotonNetwork.LocalPlayer.CustomProperties = hash;
        }
    }
Exemple #15
0
    public override void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
    {
        base.OnPlayerPropertiesUpdate(targetPlayer, changedProps);
//        Debug.Log("OGSC Player props >> " + targetPlayer.NickName + " " + changedProps.ToStringFull());

        if (targetPlayer == PhotonNetwork.LocalPlayer)
        {
            //POPULATE LOCAL PLAYER INFO
            Debug.Log("it was local that changed");
            localPlayerInfo.SetPlayerInfo(targetPlayer);

            //Display dice to select the first player
            if (!rolledDice && changedProps.ContainsKey("roll"))
            {
                //Conditioned to rematch in single
                if (!singleRematch)
                {
                    ui.StartCoroutine(ui.RollingDice((int[])changedProps["roll"]));
                }
                else
                {
                    ui.SingleRematch();
                }

                changedProps.Remove("roll");
                targetPlayer.SetCustomProperties(changedProps);
                rolledDice = true;
            }
        }
        else
        {
            //POPULATE REMOTE PLAYER INFO
//            Debug.Log("it was remote that changed");
            remotePlayerInfo.SetPlayerInfo(targetPlayer);

            //if (targetPlayer.CustomProperties.ContainsKey("rematch"))
            //{
            //    if ((bool)targetPlayer.CustomProperties["rematch"] && !(bool)PhotonNetwork.LocalPlayer.CustomProperties["rematch"])
            //    {
            //        Debug.Log("Xxxxxxxx Other wants to rematch");
            //        StartCoroutine(OtherPlayerWantsToRematch());
            //    }
            //}
        }
    }
 public void SaveData(string label, System.Object data)
 {
     if (CurrentServerUserDepth == ServerDepthLevel.Offline)
     {
         _fakeServer.DataStore.Remove(label);
         _fakeServer.DataStore.Add(label, data);
     }
     else if (CurrentServerUserDepth == ServerDepthLevel.InRoom)
     {
         ExitGames.Client.Photon.Hashtable roomProps = PhotonNetwork.CurrentRoom.CustomProperties;
         roomProps.Remove(label);
         roomProps.Add(label, data);
         PhotonNetwork.CurrentRoom.SetCustomProperties(roomProps);
     }
     else
     {
         CBUG.Error("SaveData only available when Offline or InRoom, this was called at  " + CurrentServerUserDepth.ToString() + ".");
     }
 }
Exemple #17
0
 public void OnClick_SetChar()
 {
     net.OnClick_SetID(charID);
     foreach (CharacterSelect c in canvasHold.css)
     {
         c.selectIndicator.SetActive(false);
     }
     selectIndicator.SetActive(true);
     if (hash.ContainsKey("PlayerID"))
     {
         hash.Remove("PlayerID");
     }
     hash.Add("PlayerID", charID);
     PhotonNetwork.player.SetCustomProperties(hash);
     foreach (RectTransform can in canvasHold.sel.infoObject)
     {
         can.gameObject.SetActive(false);
     }
     canvasHold.sel.infoObject[charID].gameObject.SetActive(true);
 }
        /// <summary>Removes all keys with null values.</summary>
        /// <remarks>
        /// Photon properties are removed by setting their value to null. Changes the original IDictionary!
        /// Uses lock(keysWithNullValue), which should be no problem in expected use cases.
        /// </remarks>
        /// <param name="original">The IDictionary to strip of keys with null value.</param>
        public static void StripKeysWithNullValues(this Hashtable original)
        {
            lock (keysWithNullValue)
            {
                keysWithNullValue.Clear();

                foreach (DictionaryEntry entry in original)
                {
                    if (entry.Value == null)
                    {
                        keysWithNullValue.Add(entry.Key);
                    }
                }

                for (int i = 0; i < keysWithNullValue.Count; i++)
                {
                    var key = keysWithNullValue[i];
                    original.Remove(key);
                }
            }
        }
    /// <summary>
    /// If the owner of the room, instantiates bots.
    /// </summary>
    /// <param name="teamsCount"></param>
    public void InstantiateBots(int[] teamsCount)
    {
        if (!botsIntantiated)
        {
            botsIntantiated = true;

            object owner;
            if (PhotonNetwork.player.customProperties.TryGetValue("Owner", out owner))
            {
                ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
                properties.Remove("Owner");
                PhotonNetwork.player.SetCustomProperties(properties);

                string ownerName = owner.ToString();
                if (ownerName == PhotonNetwork.player.name)
                {
                    networkLayer.InstantiateBots(teamsCount);
                }
            }
        }
    }
Exemple #20
0
    public override void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
    {
        base.OnRoomPropertiesUpdate(propertiesThatChanged);
        if (!gameBegan)
        {
            Debug.Log("Room props changed: " + propertiesThatChanged.ToStringFull());
        }

        if (propertiesThatChanged.ContainsKey("start") && !gameBegan)
        {
            //turnManager.InitializeTurnManager();
            Debug.Log("room properties summary: " + propertiesThatChanged.ToStringFull());
            Debug.Log("0000000000 ROOM PROPS: " + PhotonNetwork.CurrentRoom.CustomProperties.ToStringFull());
            Hashtable hash = PhotonNetwork.CurrentRoom.CustomProperties;
            hash.Remove("start");
            PhotonNetwork.CurrentRoom.SetCustomProperties(hash);
            Debug.Log("removed start");

            //GAME STARTED
            manager.GameStart();
            gameBegan = true;
        }
    }
Exemple #21
0
 public void RemoveProperties(string key)
 {
     customPlayerProperties.Remove(key);
     PhotonNetwork.LocalPlayer.CustomProperties = customPlayerProperties;
 }
    /// <summary>
    /// If the owner of the room, instantiates bots.
    /// </summary>
    /// <param name="teamsCount"></param>
    public void InstantiateBots(int[] teamsCount)
    {
        if (!botsIntantiated)
        {
            botsIntantiated = true;

            object owner;
            if (PhotonNetwork.player.customProperties.TryGetValue("Owner", out owner))
            {
                ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
                properties.Remove("Owner");
                PhotonNetwork.player.SetCustomProperties(properties);

                string ownerName = owner.ToString();
                if (ownerName == PhotonNetwork.player.name)
                {
                    networkLayer.InstantiateBots(teamsCount);
                }
            }
        }
    }
Exemple #23
0
    private IEnumerator TimeOutRoutine(string condition, string type)
    {
        Debug.Log("TimeOutRoutine Coroutine Initialized");
        exitTimeOutButton.SetActive(true);
        opponentPanel.SetActive(false);
        Debug.Log("Turned Off Panell");
        searchPanel.SetActive(false);
        timeOutPanel.SetActive(true);

        int outro = 0;


        if (condition == "check" && attempt == 0)
        {
            Debug.Log("Condition Check");
            attempt         += 1;
            timeOutText.text = "Hey! you must click 'ACCEPT' to join";
            outro            = 3;
            yield return(new WaitForSeconds(outro));

            StartCoroutine(OpponentFoundRoutine());
            StopCoroutine(TimeOutRoutine(condition, type));
            yield break;
        }
        else if (attempt > 0 && condition == "check")
        {
            Debug.Log("Condition Second attempt");
            attempt = 0;
            PhotonNetwork.LeaveRoom();
            opponentFound    = false;
            timeOutText.text = "Sorry, you don't seem to be around." +
                               "\nThat's ok, get back in the queue when you're ready.";
            outro = 3;
            yield return(new WaitForSeconds(outro));

            ExitSearch();
            StartCoroutine(RejoinLobby());
            StopCoroutine(TimeOutRoutine(condition, type));
            yield break;
        }
        if (condition == "local")
        {
            Debug.Log("Condition Local");
            PhotonNetwork.LeaveRoom();
            timeOutText.text = "Sorry, you don't seem to be around." +
                               "\nThat's ok, get back in the queue when you're ready.";
            outro         = 4;
            opponentFound = false;
            yield return(new WaitForSeconds(outro));

            ExitSearch();
            StartCoroutine(RejoinLobby());
            StopCoroutine(TimeOutRoutine(condition, type));
            yield break;
        }
        if (condition == "remote")
        {
            Debug.Log("Condition Remote");
            if (PhotonNetwork.InRoom)
            {
                if (PhotonNetwork.CurrentRoom.CustomProperties.ContainsKey("invitation"))
                {
                    Hashtable hash = PhotonNetwork.CurrentRoom.CustomProperties;
                    hash.Remove("invitation");
                    PhotonNetwork.CurrentRoom.SetCustomProperties(hash);
                    PhotonNetwork.CurrentRoom.IsVisible = true;
                }
                else
                {
                    Debug.Log("Doesnt contain invitation " + PhotonNetwork.CurrentRoom.CustomProperties.ToStringFull());
                }
            }
            timeOutText.text = "The other player didn’t answer in time." +
                               "\nYou've been placed back in the queue";
            outro         = 3;
            opponentFound = false;
            yield return(new WaitForSeconds(outro));

            if (!searching)
            {
                StartCoroutine(SearchingLog(type));
            }
            Debug.Log("StopCoroutine");
            StopCoroutine(TimeOutRoutine(condition, type));
            Debug.Log("yield break");
            yield break;
            Debug.Log("broke");
        }
        if (condition == "missing")
        {
            Debug.Log("Condition Missing");

            if (PhotonNetwork.InRoom)
            {
                if (PhotonNetwork.CurrentRoom.CustomProperties.ContainsKey("invitation"))
                {
                    Hashtable hash = PhotonNetwork.CurrentRoom.CustomProperties;
                    hash.Remove("invitation");
                    PhotonNetwork.CurrentRoom.SetCustomProperties(hash);
                    PhotonNetwork.CurrentRoom.IsVisible = true;
                }
                else
                {
                    Debug.Log("Doesnt contain invitation " + PhotonNetwork.CurrentRoom.CustomProperties.ToStringFull());
                }
            }

            timeOutText.text = "Sorry, the other player is missing." +
                               "\nYou've been placed back in the queue";
            outro         = 2;
            opponentFound = false;
            yield return(new WaitForSeconds(outro));

            if (!searching)
            {
                StartCoroutine(SearchingLog(type));
            }
            StopCoroutine(TimeOutRoutine(condition, type));
            yield break;
        }
        if (condition == "invitation")
        {
            //PhotonNetwork.LeaveRoom();
            Debug.Log("Condition Invitation");
            attempt          = 0;
            opponentFound    = false;
            timeOutText.text = "Sorry, the other player is missing or left";
            outro            = 3;
            yield return(new WaitForSeconds(outro));

            ExitSearch();
            StartCoroutine(RejoinLobby());
            StopCoroutine(TimeOutRoutine(condition, type));
            yield break;
        }
    }
Exemple #24
0
 public bool RemoveRoomProperty(string key)
 {
     return(_CustomRoomProperties.Remove(key) && _CustomRoomPropertiesInLobby.Remove(key));
 }
Exemple #25
0
    public void CreateButton()
    {
        if (random)
        {
            roomText.text = "滾滾滾起來";
            RoomOptions options = new RoomOptions {
                MaxPlayers = 8
            };
            options.CleanupCacheOnLeave = false;
            PhotonNetwork.CreateRoom("滾滾滾起來", options, default);
        }
        else
        {
            if (!pas.isOn)
            {
                if (roomNameCreate.text.Length < 1 || roomNameCreate.text.Length > 12)
                {
                    return;
                }
                if (RoomListManager.roomID.Count > 0)
                {
                    foreach (var room in RoomListManager.roomID)
                    {
                        if (room.Name == roomNameCreate.text)
                        {
                            PromptUI.PromptPut[4].SetActive(true);
                            return;
                        }
                        else
                        {
                            創建面板.SetActive(false);

                            isPublic = true;
                            if (noPas.ContainsKey("Public"))
                            {
                                noPas.Remove("Public");
                                noPas.Add("Public", isPublic);
                                PhotonNetwork.LocalPlayer.SetCustomProperties(noPas, null);
                            }
                            else
                            {
                                noPas.Add("Public", isPublic);
                                PhotonNetwork.LocalPlayer.SetCustomProperties(noPas, null);
                            }

                            roomText.text = roomNameCreate.text;
                            int i = int.Parse(maxplayer.transform.GetChild(0).GetComponent <Text>().text);

                            Maxplayer = (byte)i;
                            RoomOptions options = new RoomOptions();
                            options.CustomRoomProperties         = noPas;
                            options.CleanupCacheOnLeave          = false;
                            options.CustomRoomPropertiesForLobby = new string[] { "Public" };


                            PhotonNetwork.CreateRoom(roomNameCreate.text, options, default);
                            marbles.isBack = true;
                            create         = true;
                        }
                    }
                }
                else
                {
                    創建面板.SetActive(false);

                    isPublic = true;
                    if (noPas.ContainsKey("Public"))
                    {
                        noPas.Remove("Public");
                        noPas.Add("Public", isPublic);
                        PhotonNetwork.LocalPlayer.SetCustomProperties(noPas, null);
                    }
                    else
                    {
                        noPas.Add("Public", isPublic);
                        PhotonNetwork.LocalPlayer.SetCustomProperties(noPas, null);
                    }

                    roomText.text = roomNameCreate.text;
                    int i = int.Parse(maxplayer.transform.GetChild(0).GetComponent <Text>().text);

                    Maxplayer = (byte)i;
                    RoomOptions options = new RoomOptions();
                    options.CustomRoomProperties         = noPas;
                    options.CleanupCacheOnLeave          = false;
                    options.CustomRoomPropertiesForLobby = new string[] { "Public" };



                    PhotonNetwork.CreateRoom(roomNameCreate.text, options, default);
                    marbles.isBack = true;
                    create         = true;
                }
            }
            else
            {
                if (roomNameCreate.text.Length < 1 || roomNameCreate.text.Length > 12)
                {
                    return;
                }

                if (RoomListManager.roomID.Count > 0)
                {
                    foreach (var room in RoomListManager.roomID)
                    {
                        if (room.Name == roomNameCreate.text)
                        {
                            PromptUI.PromptPut[4].SetActive(true);
                            return;
                        }
                        else
                        {
                            創建面板.SetActive(false);
                            roomText.text = roomNameCreate.text;
                            int i = int.Parse(maxplayer.transform.GetChild(0).GetComponent <Text>().text);

                            Maxplayer = (byte)i;
                            RoomOptions options = new RoomOptions {
                                MaxPlayers = Maxplayer, IsVisible = false
                            };
                            options.CleanupCacheOnLeave = false;
                            PhotonNetwork.CreateRoom(roomNameCreate.text, options, default);
                            marbles.isBack = true;
                            create         = true;
                        }
                    }
                }
                else
                {
                    創建面板.SetActive(false);
                    roomText.text = roomNameCreate.text;
                    int i = int.Parse(maxplayer.transform.GetChild(0).GetComponent <Text>().text);
                    Maxplayer = (byte)i;
                    RoomOptions options = new RoomOptions {
                        MaxPlayers = Maxplayer, IsVisible = false
                    };
                    options.CleanupCacheOnLeave = false;
                    PhotonNetwork.CreateRoom(roomNameCreate.text, options, default);
                    marbles.isBack = true;
                    create         = true;
                }
            }
        }
        //if (pass != null)
        //{
        //    roomText.text = roomNameCreate.text;
        //    int i = int.Parse(maxplayer.transform.GetChild(0).GetComponent<Text>().text);
        //    Maxplayer = (byte)i;

        //    RoomOptions options = new RoomOptions();
        //    options.MaxPlayers = Maxplayer;
        //    options.CustomRoomProperties.Add("Pass", pass);
        //    options.CustomRoomPropertiesForLobby = new string[1] { "Pass" };

        //    PhotonNetwork.CreateRoom(roomNameCreate.text, options, default);
        //    marbles.isBack = true;
        //    create = true;
        //}
        if (rmnm.ContainsKey("name"))
        {
            rmnm.Remove("name");
            rmnm.Add("name", roomText.text);
            PhotonNetwork.LocalPlayer.SetCustomProperties(rmnm, null);
        }
        else
        {
            rmnm.Add("name", roomText.text);
            PhotonNetwork.LocalPlayer.SetCustomProperties(rmnm, null);
        }
    }
    /// <summary>
    /// Compares the new data with previously sent data and skips values that didn't change.
    /// </summary>
    /// <returns>True if anything has to be sent, false if nothing new or no data</returns>
    private bool DeltaCompressionWrite(PhotonView view, Hashtable data)
    {
        if (view.lastOnSerializeDataSent == null)
        {
            return true; // all has to be sent
        }

        // We can compress as we sent a full update previously (readers can re-use previous values)
        object[] lastData = view.lastOnSerializeDataSent;
        object[] currentContent = data[(byte)1] as object[];

        if (currentContent == null)
        {
            // no data to be sent
            return false;
        }

        if (lastData.Length != currentContent.Length)
        {
            // if new data isn't same length as before, we send the complete data-set uncompressed
            return true;
        }

        object[] compressedContent = new object[currentContent.Length];
        int compressedValues = 0;

        List<int> valuesThatAreChangedToNull = new List<int>();
        for (int index = 0; index < compressedContent.Length; index++)
        {
            object newObj = currentContent[index];
            object oldObj = lastData[index];
            if (this.ObjectIsSameWithInprecision(newObj, oldObj))
            {
                // compress (by using null, instead of value, which is same as before)
                compressedValues++;
                // compressedContent[index] is already null (initialized)
            }
            else
            {
                compressedContent[index] = currentContent[index];

                // value changed, we don't replace it with null
                // new value is null (like a compressed value): we have to mark it so it STAYS null instead of being replaced with previous value
                if (newObj == null)
                {
                    valuesThatAreChangedToNull.Add(index);
                }
            }
        }

        // Only send the list of compressed fields if we actually compressed 1 or more fields.
        if (compressedValues > 0)
        {
            data.Remove((byte)1); // remove the original data (we only send compressed data)

            if (compressedValues == currentContent.Length)
            {
                // all values are compressed to null, we have nothing to send
                return false;
            }

            data[(byte)2] = compressedContent; // current, compressted data is moved to key 2 to mark it as compressed
            if (valuesThatAreChangedToNull.Count > 0)
            {
                data[(byte)3] = valuesThatAreChangedToNull.ToArray(); // data that is actually null (not just cause we didn't want to send it)
            }
        }

        return true;    // some data was compressed but we need to send something
    }
Exemple #27
0
 private void OnDisable()
 {
     _myCustomProperties.Remove("CUSTOM_NUMBER");
     PhotonNetwork.LocalPlayer.CustomProperties = _myCustomProperties;
 }