Beispiel #1
0
    private void DisplayPlayerStats(MatchInfo match)
    {
        playerStatsItemsPool.ReturnAll();

        var lastRoundStats = match?.GetLastRoundStats();

        if (lastRoundStats != null)
        {
            List <uint> accountIds = lastRoundStats.reservation.account_ids;
            for (int accountIndex = 0; accountIndex < accountIds.Count; accountIndex++)
            {
                PlayerStatsItemController playerStatsItem = playerStatsItemsPool.Get();
                playerStatsItem.transform.SetAsLastSibling();

                string name = "Unknown";
                if (match.extraMatchStats != null)
                {
                    int extraAccountIndex = match.extraMatchStats.accountIds.IndexOf(accountIds[accountIndex]);
                    name = match.extraMatchStats.playerNames[extraAccountIndex];
                }
                else
                {
                    var steamId = new SteamKit2.SteamID(accountIds[accountIndex], SteamKit2.EUniverse.Public, SteamKit2.EAccountType.Individual);
                    name = steamId.AccountID.ToString();

                    var friend = SteamController.steamInScene.GetFriendWithAccountId(steamId);
                    if (friend != null)
                    {
                        name = friend.GetDisplayName();
                    }
                    else
                    {
                        if (userNames.ContainsKey(steamId))
                        {
                            name = userNames[steamId];
                        }
                        else
                        {
                            if (SteamController.steamInScene.IsLoggedIn)
                            {
                                SteamController.steamInScene.RequestProfileInfo(steamId, (profileInfo) =>
                                {
                                    TaskManagerController.RunAction(() =>
                                    {
                                        //Debug.Log(profileInfo.Result);
                                        if (!string.IsNullOrEmpty(profileInfo.RealName))
                                        {
                                            userNames[steamId]            = profileInfo.RealName;
                                            playerStatsItem.nameText.text = profileInfo.RealName;
                                        }
                                    });
                                });
                            }
                        }
                    }
                }

                playerStatsItem.nameText.text         = name;
                playerStatsItem.killsCountText.text   = lastRoundStats.kills[accountIndex].ToString();
                playerStatsItem.assistsCountText.text = lastRoundStats.assists[accountIndex].ToString();
                playerStatsItem.deathsCountText.text  = lastRoundStats.deaths[accountIndex].ToString();
                playerStatsItem.scoreText.text        = lastRoundStats.scores[accountIndex].ToString();
            }
        }
    }