/// <summary> /// Loads the leaderboard data. This is the "top level" call /// to load leaderboard data. A token for fetching scores is created /// based on the parameters. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start of scores location</param> /// <param name="rowCount">Row count.</param> /// <param name="collection">Collection social or public</param> /// <param name="timeSpan">Time span of leaderboard</param> /// <param name="playerId">Player identifier.</param> /// <param name="callback">Callback.</param> public void LoadLeaderboardData(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, string playerId, Action <LeaderboardScoreData> callback) { //Create a token we'll use to load scores later. NativeScorePageToken nativeToken = new NativeScorePageToken( C.LeaderboardManager_ScorePageToken( mServices.AsHandle(), leaderboardId, (Types.LeaderboardStart)start, (Types.LeaderboardTimeSpan)timeSpan, (Types.LeaderboardCollection)collection)); ScorePageToken token = new ScorePageToken(nativeToken, leaderboardId, collection, timeSpan); // First fetch the leaderboard to get the title C.LeaderboardManager_Fetch(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, leaderboardId, InternalFetchCallback, Callbacks.ToIntPtr <FetchResponse>((rsp) => HandleFetch(token, rsp, playerId, rowCount, callback), FetchResponse.FromPointer)); }
/// <summary> /// Loads the scores using the provided parameters. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start either top scores, or player centered.</param> /// <param name="rowCount">Row count. the number of rows to return.</param> /// <param name="collection">Collection. social or public</param> /// <param name="timeSpan">Time span. daily, weekly, all-time</param> /// <param name="callback">Callback to invoke when completed.</param> public void LoadScores( string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { if (!IsAuthenticated()) { GooglePlayGames.OurUtils.Logger.e("LoadScores can only be called after authentication."); callback(new LeaderboardScoreData( leaderboardId, ResponseStatus.NotAuthorized)); return; } mClient.LoadScores( leaderboardId, start, rowCount, collection, timeSpan, callback); }
public void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { throw new System.NotImplementedException(); }
public virtual void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { throw new NotSupportedException("unsupported"); }
public void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData(leaderboardId, ResponseStatus.LicenseCheckFailed)); } }
///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.LoadScores"/> public void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { GameServices().LeaderboardManager().LoadLeaderboardData( leaderboardId, start, rowCount, collection, timeSpan, this.mUser.id, callback ); }
public void LoadLeaderboardData(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, string playerId, Action <LeaderboardScoreData> callback) { NativeScorePageToken internalObject = new NativeScorePageToken(GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_ScorePageToken(mServices.AsHandle(), leaderboardId, (Types.LeaderboardStart)start, (Types.LeaderboardTimeSpan)timeSpan, (Types.LeaderboardCollection)collection)); ScorePageToken token = new ScorePageToken(internalObject, leaderboardId, collection, timeSpan); GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_Fetch(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, leaderboardId, InternalFetchCallback, Callbacks.ToIntPtr(delegate(FetchResponse rsp) { HandleFetch(token, rsp, playerId, rowCount, callback); }, FetchResponse.FromPointer)); }
public void LoadScores(Action <LeaderboardScoreData> callback, LeaderboardStart start = LeaderboardStart.PlayerCentered, LeaderboardCollection collection = LeaderboardCollection.Public, LeaderboardTimeSpan timeSpan = LeaderboardTimeSpan.AllTime, int rowCount = 100, string leaderboardId = null) { leaderboardId = leaderboardId ?? _defaultLeaderBoardId; PlayGamesPlatform.Instance.LoadScores(leaderboardId, start, rowCount, collection, timeSpan, callback); }
///<summary></summary> /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.LoadScores"/> public void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action <LeaderboardScoreData> callback) { using (var client = getLeaderboardsClient()) { string loadScoresMethod = start == LeaderboardStart.TopScores ? "loadTopScores" : "loadPlayerCenteredScores"; using (var task = client.Call <AndroidJavaObject>( loadScoresMethod, leaderboardId, AndroidJavaConverter.ToLeaderboardVariantTimeSpan(timeSpan), AndroidJavaConverter.ToLeaderboardVariantCollection(collection), rowCount)) { AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>( task, annotatedData => { using (var leaderboardScores = annotatedData.Call <AndroidJavaObject>("get")) { InvokeCallbackOnGameThread(callback, CreateLeaderboardScoreData( leaderboardId, collection, timeSpan, annotatedData.Call <bool>("isStale") ? ResponseStatus.SuccessWithStale : ResponseStatus.Success, leaderboardScores)); leaderboardScores.Call("release"); } }); AndroidTaskUtils.AddOnFailureListener( task, exception => { Debug.Log("LoadScores failed"); InvokeCallbackOnGameThread(callback, new LeaderboardScoreData(leaderboardId, ResponseStatus.InternalError)); }); } } }
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); } }); }
/// <summary> /// Loads the scores using the provided parameters. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start either top scores, or player centered.</param> /// <param name="rowCount">Row count. the number of rows to return.</param> /// <param name="collection">Collection. social or public</param> /// <param name="timeSpan">Time span. daily, weekly, all-time</param> /// <param name="callback">Callback.</param> public void LoadScores(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action<LeaderboardScoreData> callback) { if (!IsAuthenticated()) { GooglePlayGames.OurUtils.Logger.e("LoadScores can only be called after authentication."); callback(new LeaderboardScoreData(leaderboardId, ResponseStatus.NotAuthorized)); return; } mClient.LoadScores(leaderboardId, start, rowCount, collection, timeSpan, callback); }
/// <summary> /// Loads the score data for the given leaderboard. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start indicating the top scores or player centric</param> /// <param name="rowCount">Row count.</param> /// <param name="collection">Collection to display.</param> /// <param name="timeSpan">Time span.</param> /// <param name="callback">Callback to invoke when complete.</param> public void LoadScores( string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, Action<LeaderboardScoreData> callback) { LogUsage(); if (callback != null) { callback(new LeaderboardScoreData( leaderboardId, ResponseStatus.LicenseCheckFailed)); } }
/// <summary> /// Loads the leaderboard data. This is the "top level" call /// to load leaderboard data. A token for fetching scores is created /// based on the parameters. /// </summary> /// <param name="leaderboardId">Leaderboard identifier.</param> /// <param name="start">Start of scores location</param> /// <param name="rowCount">Row count.</param> /// <param name="collection">Collection social or public</param> /// <param name="timeSpan">Time span of leaderboard</param> /// <param name="playerId">Player identifier.</param> /// <param name="callback">Callback.</param> public void LoadLeaderboardData(string leaderboardId, LeaderboardStart start, int rowCount, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan, string playerId, Action<LeaderboardScoreData> callback) { //Create a token we'll use to load scores later. NativeScorePageToken nativeToken = new NativeScorePageToken( C.LeaderboardManager_ScorePageToken( mServices.AsHandle(), leaderboardId, (Types.LeaderboardStart)start, (Types.LeaderboardTimeSpan)timeSpan, (Types.LeaderboardCollection)collection)); ScorePageToken token = new ScorePageToken(nativeToken, leaderboardId, collection, timeSpan); // First fetch the leaderboard to get the title C.LeaderboardManager_Fetch(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, leaderboardId, InternalFetchCallback, Callbacks.ToIntPtr<FetchResponse>((rsp) => HandleFetch(token, rsp, playerId, rowCount, callback), FetchResponse.FromPointer)); }