public void ShowScores(GameData gameData) { for (int i = 0, count = gameData.Players.Count; i < count; ++i) { PlayerData currentPlayer = gameData.Players[i]; GameObject newColumnObj = GameObject.Instantiate(Resources.Load <GameObject>("Scoring/ScoreContainer"), ScoreContainer); ScoreColumn newColumn = newColumnObj.GetComponent <ScoreColumn>(); int roundNumber = gameData.IsFinished ? 13 : gameData.CurrentRoundNumber; newColumn.SetPlayerScore(currentPlayer, roundNumber); Columns.Add(newColumn); } gameObject.SetActive(true); }
public void LoadLeaderboard() { LeaderboardData?.Clear(); NameColumn.Clear(); ScoreColumn.Clear(); EntryCount = 0; var text = File.ReadAllText(LeaderboardPath); try { LeaderboardData = JsonConvert.DeserializeObject <List <LeaderboardEntry> >(text); foreach (var entry in LeaderboardData) { NameColumn.AddParagraph(entry.Name); ScoreColumn.AddParagraph(entry.Score); ++EntryCount; } } catch (Exception ex) { NameColumn.AddParagraph("Error parsing leaderboard!"); EntryCount = -1; Console.WriteLine(ex); } }