public void ShowLeaderBoard() { for (int i = 0; i < ProfileParent.transform.childCount; i++) { Destroy(ProfileParent.transform.GetChild(i).gameObject); } MainLeaderBoard m = new MainLeaderBoard(); m.GetTopPlayersInBackground(100, leaderboardResponse => { // Checking if response was fetched successfully if (leaderboardResponse.Successful) { for (int i = 0; i < leaderboardResponse.Body.UsersProfile.Count; i++) { BacktoryLeaderBoard.UserProfile topPlayer = leaderboardResponse.Body.UsersProfile[i]; string username = topPlayer.UserBriefProfile.UserName; IList <int> scores = topPlayer.Scores; Sprite a = new Sprite(); switch (i + 1) { case 1: a = firstRank; break; case 2: a = SecondRank; break; case 3: a = ThirdRank; break; default: a = normalRank; break; } Instantiate(UserPrefab, ProfileParent.transform).GetComponent <Profile>().RePaint(username, scores[0], scores[1], i + 1, medals[scores[1] / 8], a); // Logging best player Debug.Log("best player is: " + username + " Exp: " + scores[0] + " Lvl: " + scores[1]); } } else { print("SomeThingWentWrong"); LoadingPanel.SetActive(false); } }); m.GetPlayerRankInBackground(rankResponse => { // Check if backtory returned result successfully if (rankResponse.Successful) { IList <int> scores = rankResponse.Body.Scores; Sprite a = new Sprite(); switch (rankResponse.Body.Rank) { case 1: a = firstRank; break; case 2: a = SecondRank; break; case 3: a = ThirdRank; break; default: a = normalRank; break; } UserProfile.RePaint(PlayerPrefs.GetString("Username"), scores[0], scores[1], rankResponse.Body.Rank, medals[scores[1] / 8], a); LoadingPanel.SetActive(false); LeadrBoardPanel.SetTrigger("Enter"); } else { // do something based on error code LoadingPanel.SetActive(false); } }); }
public void exitLeaderBoard() { playSound("Button"); LeadrBoardPanel.SetTrigger("Idle"); }