/// <summary>
        /// Send a player to all listeners of OnServerPlayerRequest
        /// </summary>
        /// <param name="args"></param>
        private void OnSendPlayerScoreCallback(SocketIOEvent args)
        {
            if (args.data.ToString() == "{}")
            {
                OnNullServerPlayerRequest();
                return;
            }

            string      name            = args.data.GetField("player").GetField("_name").ToString();
            float       score           = float.Parse(args.data.GetField("player").GetField("_score").ToString());
            PlayerScore requestedPlayer = new PlayerScore(name, score);

            OnServerPlayerRequest(requestedPlayer);
        }
        /// <summary>
        /// Send list of player to all listeners of OnServerPlayersUpdate
        /// </summary>
        /// <param name="args"></param>
        private void OnSendPlayersCallback(SocketIOEvent args)
        {
            List <PlayerScore> playerScore = new List <PlayerScore>();

            foreach (var i in args.data.GetField("players").list)
            {
                string name = i.GetField("_name").ToString();
                name = name.Replace("\"", "");

                float score = float.Parse(i.GetField("_score").ToString());

                PlayerScore ps = new PlayerScore(name, score);
                playerScore.Add(ps);
            }

            OnServerPlayersUpdate(playerScore);
        }
Пример #3
0
 private void DisplayPlayer(PlayerScore ps)
 {
     _playerNameText.text  = ps.name.Trim('"');
     _playerScoreText.text = ps.score.ToString("F" + RankingSystemController.Instance.floatPrecision.ToString());
 }