예제 #1
0
        /// <summary>
        /// Sets the player number.
        /// It's not recommanded to manually interfere with the playerNumbering, but possible.
        /// </summary>
        /// <param name="player">Player.</param>
        /// <param name="playerNumber">Player number.</param>
        public static void SetPlayerNumber(this Player player, int playerNumber)
        {
            if (player == null)
            {
                return;
            }

            if (PhotonNetwork.OfflineMode)
            {
                return;
            }

            if (playerNumber < 0)
            {
                Debug.LogWarning("Setting invalid playerNumber: " + playerNumber + " for: " + player.ToStringFull());
            }

            if (!PhotonNetwork.IsConnectedAndReady)
            {
                Debug.LogWarning("SetPlayerNumber was called in state: " + PhotonNetwork.NetworkClientState + ". Not IsConnectedAndReady.");
                return;
            }

            int current = player.GetPlayerNumber();

            if (current != playerNumber)
            {
                Debug.Log("PlayerNumbering: Set number " + playerNumber);
                player.SetCustomProperties(new Hashtable()
                {
                    { PlayerNumbering.RoomPlayerIndexedProp, (byte)playerNumber }
                });
            }
        }
예제 #2
0
        private void OnReadyButtonClicked()
        {
            ExitGamesHashtable exitGamesHashtable = player.CustomProperties;

            exitGamesHashtable[NetworkHelper.Constants.PLAYER_READY] = !readyValue;

            player.SetCustomProperties(exitGamesHashtable);
        }
    public static void SetDeaths(this Photon.Realtime.Player player, int newDeaths)
    {
        Hashtable Deaths = new Hashtable();          // using PUN's implementation of Hashtable

        Deaths[PunPlayerKillsDeaths.PlayerDeathProp] = newDeaths;

        player.SetCustomProperties(Deaths);          // this locally sets the kills and will sync it in-game asap.
    }
    public static void AddDeath(this Photon.Realtime.Player player, int deathToAddToCurrent)
    {
        int current = player.GetDeaths();

        current = current + deathToAddToCurrent;

        Hashtable deaths = new Hashtable();          // using PUN's implementation of Hashtable

        deaths[PunPlayerKillsDeaths.PlayerDeathProp] = current;

        player.SetCustomProperties(deaths);          // this locally sets the kills and will sync it in-game asap.
    }
예제 #5
0
    public void PlayerReady(bool ready)
    {
        Hashtable table = new Hashtable();

        table.Add("Room_PlayerReady", ready);
        player.SetCustomProperties(table);
        readyText.text = ready ? lC.GetWord("READY") : lC.GetWord("NOT_READY");
        if (player.IsLocal)
        {
            EventManager.instance.SendOnPlayerReady(player.NickName, ready);
        }
    }
예제 #6
0
    void IncreaseKillsOrDeathsPlayerCustomProps(Photon.Realtime.Player player, string key)
    {
        Hashtable current = player.CustomProperties;
        Hashtable hash    = new Hashtable();

        foreach (string _key in current.Keys)
        {
            if (_key != key)
            {
                hash.Add(_key, current[_key]);
            }
        }
        object currentKillsValue = current[key];

        hash.Add(key, currentKillsValue != null ? (int)currentKillsValue + 1 : 1);
        player.SetCustomProperties(hash);
    }
예제 #7
0
파일: Player.cs 프로젝트: niceoasi/Unity
        public void AddUserProperties(KeyValuePair <object, object> userProperty, bool reqSyncData = true)
        {
            if (SalinTokens.ValidateTokenUserToken() == false)
            {
                return;
            }

            if (this.userProperties.ContainsKey(userProperty.Key) == true)
            {
                Debug.Log("The key is already contains UserProperties. Update the value");
                this.userProperties[userProperty.Key] = userProperty.Value;
            }
            else
            {
                this.userProperties.Add(userProperty.Key, userProperty.Value);
            }

#if PHOTON_UNITY_NETWORKING
            if (reqSyncData == true)
            {
                if (userId == UserManager.Instance.userID)
                {
                    PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable()
                    {
                        { userProperty.Key, userProperty.Value }
                    });
                }
                else
                {
                    Photon.Realtime.Player photonPlayer = Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(dynamicCodeInRoom);
                    photonPlayer.SetCustomProperties(new Hashtable()
                    {
                        { userProperty.Key, userProperty.Value }
                    });
                }
            }
#endif
        }
예제 #8
0
        private void LockMerchant(string clientID, string merchantname)
        {
            SoundManager.Ins.Play(AudioClipEnum.CardDraw);

            var merchantPrefab = listInstantMerchant.Find(x => x.Name == merchantname);
            var playerCard     = playerCards.Find(x => x.GetClientID() == clientID);

            var _merchant = Instantiate(merchantPrefab, playerCard.transform);

            _merchant.Init();
            _merchant.gameObject.SetActive(false);

            playerCard.SetInfo(_merchant);

            if (PhotonNetwork.IsMasterClient)
            {
                // Set player properties for choosen merchant
                Photon.Realtime.Player            player             = PhotonNetwork.PlayerList.First(x => x.UserId == clientID);
                ExitGames.Client.Photon.Hashtable merchantProperties = new ExitGames.Client.Photon.Hashtable();
                merchantProperties.Add("merchantType", (int)(merchantPrefab.TagName));
                player.SetCustomProperties(merchantProperties);

                currentTurnPlayerIndex++;

                if (currentTurnPlayerIndex < listPlayer.Count)
                {
                    string nextClientID = listPlayer[currentTurnPlayerIndex].UserId;
                    photonView.RPC("BeginTurn", RpcTarget.AllBufferedViaServer, nextClientID);
                }
                else
                {
                    photonView.RPC("MoveToPlayScene", RpcTarget.AllBufferedViaServer);

                    photonView.RPC("BeginTurn", RpcTarget.AllBufferedViaServer, "-1");
                }
            }
        }
예제 #9
0
파일: Player.cs 프로젝트: niceoasi/Unity
        public void SetUserProperties(Dictionary <object, object> userProperties, bool reqSyncData = true)
        {
            if (SalinTokens.ValidateTokenUserToken() == false)
            {
                return;
            }

            this.userProperties = userProperties;

#if PHOTON_UNITY_NETWORKING
            if (reqSyncData == true)
            {
                Hashtable ht = new Hashtable();

                var eProp = userProperties.GetEnumerator();
                while (eProp.MoveNext() == true)
                {
                    ht.Add(eProp.Current.Key, eProp.Current.Value);
                }

                if (ht.Count == 0)
                {
                    return;
                }

                if (userId == UserManager.Instance.userID)
                {
                    PhotonNetwork.LocalPlayer.SetCustomProperties((Hashtable)userProperties);
                }
                else
                {
                    Photon.Realtime.Player photonPlayer = Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(dynamicCodeInRoom);
                    photonPlayer.SetCustomProperties((Hashtable)userProperties);
                }
            }
#endif
        }
예제 #10
0
파일: Player.cs 프로젝트: niceoasi/Unity
        public void SetAllowInvite(bool allow, bool reqSyncData = true)
        {
            allowInvite = allow;

#if PHOTON_UNITY_NETWORKING
            if (reqSyncData == false)
            {
                return;
            }

            Hashtable ht = new Hashtable();
            ht.Add(PlayerKey.AllowInvite, allowInvite);

            if (userId == UserManager.Instance.userID)
            {
                PhotonNetwork.LocalPlayer.SetCustomProperties(ht);
            }
            else
            {
                Photon.Realtime.Player photonPlayer = Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(dynamicCodeInRoom);
                photonPlayer.SetCustomProperties(ht);
            }
#endif
        }
예제 #11
0
파일: Player.cs 프로젝트: niceoasi/Unity
        public void RemoveUserProperties(string userPropertyKey, bool reqSyncData = true)
        {
            if (SalinTokens.ValidateTokenUserToken() == false)
            {
                return;
            }

            if (userProperties.ContainsKey(userPropertyKey) == false)
            {
                Debug.Log("The key is not in the UserProperties.");
                return;
            }

            userProperties.Remove(userPropertyKey);

#if PHOTON_UNITY_NETWORKING
            if (reqSyncData == true)
            {
                if (userId == UserManager.Instance.userID)
                {
                    PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable()
                    {
                        { userPropertyKey, null }
                    });
                }
                else
                {
                    Photon.Realtime.Player photonPlayer = Photon.Pun.PhotonNetwork.CurrentRoom.GetPlayer(dynamicCodeInRoom);
                    photonPlayer.SetCustomProperties(new Hashtable()
                    {
                        { userPropertyKey, null }
                    });
                }
            }
#endif
        }
예제 #12
0
 public void ClickReadyButton(Photon.Realtime.Player player, bool isReady)
 {
     ExitGames.Client.Photon.Hashtable table = new ExitGames.Client.Photon.Hashtable();
     table.Add("isReady", isReady);
     player.SetCustomProperties(table);
 }