internal void ReceiveScoreForLocalUser(string leaderboardId, Action <LeaderboardPlayerModel[]> result) { platform.LoadScores( leaderboardId, LeaderboardStart.TopScores, 1, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (data) => { Debug.Log("-> Leaderboard data valid: " + data.Valid); Debug.Log("-> Leaderboard status: " + data.Status); if (data.Valid) { Debug.Log("-> Scores count returned: " + data.Scores.Length); IScore playerScore = data.PlayerScore; string[] ids = new string[] { playerScore.userID }; LeaderboardPlayerModel[] players = new LeaderboardPlayerModel[1]; players[0] = new LeaderboardPlayerModel(); players[0].score = (int)playerScore.value; players[0].rank = playerScore.rank; LoadUsers(ids, players, result); } else { Debug.LogWarning("Leaderboard: Leaderboard data is invalid."); result.Invoke(null); } }); }
public void ReceiveScore(int nrUsersNeed, LeaderboardStart startLocation, string leaderboardId, Action <LeaderboardPlayerModel[]> result) { platform.LoadScores( leaderboardId, startLocation, nrUsersNeed, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (data) => { Debug.Log("-> Leaderboard data valid: " + data.Valid); Debug.Log("-> Leaderboard status: " + data.Status); if (data.Valid) { int nrUsersReal = Math.Min(nrUsersNeed, data.Scores.Length); Debug.Log("-> Scores count returned: " + nrUsersReal); //Show LocalUser score IScore playerScore = data.PlayerScore; Debug.LogFormat("LocalPlayer. Name: {0}; Score: {1}", platform.GetUserDisplayName(), playerScore.value); //Get Data about the rest users LeaderboardPlayerModel[] players = new LeaderboardPlayerModel[nrUsersReal]; string[] ids = new string[nrUsersReal]; for (int a = 0; a < nrUsersReal; ++a) { IScore score = data.Scores[a]; players[a] = new LeaderboardPlayerModel(); players[a].score = (int)score.value; players[a].rank = score.rank; ids[a] = score.userID; } LoadUsers(ids, players, result); } else { Debug.LogWarning("Leaderboard: Leaderboard data is invalid."); result.Invoke(null); } }); }