internal void HandleFetchScorePage(LeaderboardScoreData data, ScorePageToken token, FetchScorePageResponse rsp, Action <LeaderboardScoreData> callback)
        {
            data.Status = (ResponseStatus)rsp.GetStatus();
            if (rsp.GetStatus() != CommonErrorStatus.ResponseStatus.VALID && rsp.GetStatus() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE)
            {
                callback(data);
            }
            NativeScorePage scorePage = rsp.GetScorePage();

            if (!scorePage.Valid())
            {
                callback(data);
            }
            if (scorePage.HasNextScorePage())
            {
                data.NextPageToken = new ScorePageToken(scorePage.GetNextScorePageToken(), token.LeaderboardId, token.Collection, token.TimeSpan);
            }
            if (scorePage.HasPrevScorePage())
            {
                data.PrevPageToken = new ScorePageToken(scorePage.GetPreviousScorePageToken(), token.LeaderboardId, token.Collection, token.TimeSpan);
            }
            foreach (NativeScoreEntry item in scorePage)
            {
                data.AddScore(item.AsScore(data.Id));
            }
            callback(data);
        }
Ejemplo n.º 2
0
 ///<summary></summary>
 /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.LoadMoreScores"/>
 public void LoadMoreScores(ScorePageToken token, int rowCount,
                            Action <LeaderboardScoreData> callback)
 {
     callback = AsOnGameThreadCallback(callback);
     GameServices().LeaderboardManager().LoadScorePage(null,
                                                       rowCount, token, callback);
 }
Ejemplo n.º 3
0
        ///<summary></summary>
        /// <seealso cref="GooglePlayGames.BasicApi.IPlayGamesClient.LoadMoreScores"/>
        public void LoadMoreScores(ScorePageToken token, int rowCount,
                                   Action <LeaderboardScoreData> callback)
        {
            using (var client = getLeaderboardsClient())
                using (var task = client.Call <AndroidJavaObject>("loadMoreScores",
                                                                  token.InternalObject, rowCount, AndroidJavaConverter.ToPageDirection(token.Direction)))
                {
                    AndroidTaskUtils.AddOnSuccessListener <AndroidJavaObject>(
                        task,
                        annotatedData =>
                    {
                        using (var leaderboardScores = annotatedData.Call <AndroidJavaObject>("get"))
                        {
                            InvokeCallbackOnGameThread(callback, CreateLeaderboardScoreData(
                                                           token.LeaderboardId,
                                                           token.Collection,
                                                           token.TimeSpan,
                                                           annotatedData.Call <bool>("isStale")
                                    ? ResponseStatus.SuccessWithStale
                                    : ResponseStatus.Success,
                                                           leaderboardScores));
                            leaderboardScores.Call("release");
                        }
                    });

                    AndroidTaskUtils.AddOnFailureListener(
                        task,
                        exception =>
                    {
                        Debug.Log("LoadMoreScores failed");
                        InvokeCallbackOnGameThread(callback,
                                                   new LeaderboardScoreData(token.LeaderboardId, ResponseStatus.InternalError));
                    });
                }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the fetch of a specific leaderboard definition.  This
        /// is called with the expectation that the leaderboard summary and
        /// scores are also needed.
        /// </summary>
        /// <param name="token">token for the current fetching request.</param>
        /// <param name="response">Response.</param>
        /// <param name="selfPlayerId">Self player identifier.</param>
        /// <param name="maxResults">Number of scores to return.</param>
        /// <param name="callback">Callback.</param>
        internal void HandleFetch(ScorePageToken token,
                                  FetchResponse response,
                                  string selfPlayerId,
                                  int maxResults,
                                  Action <LeaderboardScoreData> callback)
        {
            LeaderboardScoreData data =
                new LeaderboardScoreData(
                    token.LeaderboardId, (ResponseStatus)response.GetStatus());

            if (response.GetStatus() != Status.ResponseStatus.VALID &&
                response.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE)
            {
                Logger.w("Error returned from fetch: " + response.GetStatus());
                callback(data);
                return;
            }

            data.Title = response.Leaderboard().Title();
            data.Id    = token.LeaderboardId;

            // now fetch the summary of the leaderboard.

            C.LeaderboardManager_FetchScoreSummary(mServices.AsHandle(),
                                                   Types.DataSource.CACHE_OR_NETWORK,
                                                   token.LeaderboardId,
                                                   (Types.LeaderboardTimeSpan)token.TimeSpan,
                                                   (Types.LeaderboardCollection)token.Collection,
                                                   InternalFetchSummaryCallback,
                                                   Callbacks.ToIntPtr <FetchScoreSummaryResponse>((rsp) =>
                                                                                                  HandleFetchScoreSummary(data, rsp, selfPlayerId, maxResults, token, callback),
                                                                                                  FetchScoreSummaryResponse.FromPointer)
                                                   );
        }
Ejemplo n.º 5
0
        internal void HandleFetchScoreSummary(LeaderboardScoreData data,
                                              FetchScoreSummaryResponse response,
                                              string selfPlayerId, int maxResults,
                                              ScorePageToken token, Action <LeaderboardScoreData> callback)
        {
            if (response.GetStatus() != Status.ResponseStatus.VALID &&
                response.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE)
            {
                Logger.w("Error returned from fetchScoreSummary: " + response);
                data.Status = (ResponseStatus)response.GetStatus();
                callback(data);
                return;
            }

            NativeScoreSummary summary = response.GetScoreSummary();

            data.ApproximateCount = summary.ApproximateResults();
            data.PlayerScore      = summary.LocalUserScore().AsScore(data.Id, selfPlayerId);


            // if the maxResults is 0, no scores are needed, so we are done.
            if (maxResults <= 0)
            {
                callback(data);
                return;
            }

            LoadScorePage(data, maxResults, token, callback);
        }
Ejemplo n.º 6
0
        /// <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));
        }
Ejemplo n.º 7
0
 public void LoadScorePage(LeaderboardScoreData data, int maxResults, ScorePageToken token, Action <LeaderboardScoreData> callback)
 {
     if (data == null)
     {
         data = new LeaderboardScoreData(token.LeaderboardId);
     }
     GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_FetchScorePage(this.mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, ((BaseReferenceHolder)token.InternalObject).AsPointer(), (uint)maxResults, new GooglePlayGames.Native.Cwrapper.LeaderboardManager.FetchScorePageCallback(LeaderboardManager.InternalFetchScorePage), Callbacks.ToIntPtr <FetchScorePageResponse>((Action <FetchScorePageResponse>)(rsp => this.HandleFetchScorePage(data, token, rsp, callback)), new Func <IntPtr, FetchScorePageResponse>(FetchScorePageResponse.FromPointer)));
 }
        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));
        }
Ejemplo n.º 9
0
 public void LoadMoreScores(ScorePageToken token, int rowCount, Action <LeaderboardScoreData> callback)
 {
     if (!this.IsAuthenticated())
     {
         Logger.e("LoadMoreScores can only be called after authentication.");
         callback(new LeaderboardScoreData(token.LeaderboardId, ResponseStatus.NotAuthorized));
     }
     else
     {
         this.mClient.LoadMoreScores(token, rowCount, callback);
     }
 }
        public void LoadScorePage(LeaderboardScoreData data, int maxResults, ScorePageToken token, Action <LeaderboardScoreData> callback)
        {
            if (data == null)
            {
                data = new LeaderboardScoreData(token.LeaderboardId);
            }
            NativeScorePageToken nativeScorePageToken = (NativeScorePageToken)token.InternalObject;

            GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_FetchScorePage(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, nativeScorePageToken.AsPointer(), (uint)maxResults, InternalFetchScorePage, Callbacks.ToIntPtr(delegate(FetchScorePageResponse rsp)
            {
                HandleFetchScorePage(data, token, rsp, callback);
            }, FetchScorePageResponse.FromPointer));
        }
Ejemplo n.º 11
0
        public void LoadMoreScores(ScorePageToken token, int rowCount,
                                   Action <LeaderboardScoreData> callback)
        {
            if (!IsAuthenticated())
            {
                GooglePlayGames.OurUtils.Logger.e("LoadMoreScores can only be called after authentication.");
                callback(new LeaderboardScoreData(token.LeaderboardId,
                                                  ResponseStatus.NotAuthorized));
                return;
            }

            mClient.LoadMoreScores(token, rowCount, callback);
        }
        internal void HandleFetch(ScorePageToken token, FetchResponse response, string selfPlayerId, int maxResults, Action <LeaderboardScoreData> callback)
        {
            LeaderboardScoreData data = new LeaderboardScoreData(token.LeaderboardId, (ResponseStatus)response.GetStatus());

            if (response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID && response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE)
            {
                Logger.w("Error returned from fetch: " + response.GetStatus());
                callback(data);
            }
            else
            {
                data.Title = response.Leaderboard().Title();
                data.Id    = token.LeaderboardId;
                GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_FetchScoreSummary(mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, token.LeaderboardId, (Types.LeaderboardTimeSpan) token.TimeSpan, (Types.LeaderboardCollection) token.Collection, InternalFetchSummaryCallback, Callbacks.ToIntPtr(delegate(FetchScoreSummaryResponse rsp)
                {
                    HandleFetchScoreSummary(data, rsp, selfPlayerId, maxResults, token, callback);
                }, FetchScoreSummaryResponse.FromPointer));
            }
        }
Ejemplo n.º 13
0
        internal void HandleFetchScorePage(LeaderboardScoreData data,
                                           ScorePageToken token,
                                           FetchScorePageResponse rsp, Action <LeaderboardScoreData> callback)
        {
            data.Status = (ResponseStatus)rsp.GetStatus();
            // add the scores that match the criteria
            if (rsp.GetStatus() != Status.ResponseStatus.VALID &&
                rsp.GetStatus() != Status.ResponseStatus.VALID_BUT_STALE)
            {
                callback(data);
            }

            NativeScorePage page = rsp.GetScorePage();

            if (!page.Valid())
            {
                callback(data);
            }

            if (page.HasNextScorePage())
            {
                data.NextPageToken = new ScorePageToken(
                    page.GetNextScorePageToken(),
                    token.LeaderboardId,
                    token.Collection,
                    token.TimeSpan);
            }
            if (page.HasPrevScorePage())
            {
                data.PrevPageToken = new ScorePageToken(
                    page.GetPreviousScorePageToken(),
                    token.LeaderboardId,
                    token.Collection,
                    token.TimeSpan);
            }

            foreach (NativeScoreEntry ent in page)
            {
                data.AddScore(ent.AsScore(data.Id));
            }

            callback(data);
        }
Ejemplo n.º 14
0
 internal void HandleFetch(ScorePageToken token, FetchResponse response, string selfPlayerId, int maxResults, Action <LeaderboardScoreData> callback)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: variable of a compiler-generated type
     LeaderboardManager.\u003CHandleFetch\u003Ec__AnonStorey165 fetchCAnonStorey165 = new LeaderboardManager.\u003CHandleFetch\u003Ec__AnonStorey165();
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.selfPlayerId = selfPlayerId;
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.maxResults = maxResults;
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.token = token;
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.callback = callback;
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.\u003C\u003Ef__this = this;
     // ISSUE: reference to a compiler-generated field
     // ISSUE: reference to a compiler-generated field
     fetchCAnonStorey165.data = new LeaderboardScoreData(fetchCAnonStorey165.token.LeaderboardId, (GooglePlayGames.BasicApi.ResponseStatus)response.GetStatus());
     if (response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID && response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE)
     {
         Logger.w("Error returned from fetch: " + (object)response.GetStatus());
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         fetchCAnonStorey165.callback(fetchCAnonStorey165.data);
     }
     else
     {
         // ISSUE: reference to a compiler-generated field
         fetchCAnonStorey165.data.Title = response.Leaderboard().Title();
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         fetchCAnonStorey165.data.Id = fetchCAnonStorey165.token.LeaderboardId;
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated field
         // ISSUE: reference to a compiler-generated method
         GooglePlayGames.Native.Cwrapper.LeaderboardManager.LeaderboardManager_FetchScoreSummary(this.mServices.AsHandle(), Types.DataSource.CACHE_OR_NETWORK, fetchCAnonStorey165.token.LeaderboardId, (Types.LeaderboardTimeSpan)fetchCAnonStorey165.token.TimeSpan, (Types.LeaderboardCollection)fetchCAnonStorey165.token.Collection, new GooglePlayGames.Native.Cwrapper.LeaderboardManager.FetchScoreSummaryCallback(LeaderboardManager.InternalFetchSummaryCallback), Callbacks.ToIntPtr <FetchScoreSummaryResponse>(new Action <FetchScoreSummaryResponse>(fetchCAnonStorey165.\u003C\u003Em__A2), new Func <IntPtr, FetchScoreSummaryResponse>(FetchScoreSummaryResponse.FromPointer)));
     }
 }
Ejemplo n.º 15
0
    private void LoadMoreScores(ScorePageToken token)
    {
        PlayGamesPlatform.Instance.LoadMoreScores(
            token,
            20,
            (LeaderboardScoreData data) => {
            List <string> userIDs = new List <string>();

            Dictionary <string, IScore> userScores = new Dictionary <string, IScore>();
            for (int i = 0; i < data.Scores.Length; i++)
            {
                IScore score = data.Scores[i];
                userIDs.Add(score.userID);
                userScores[score.userID] = score;
            }

            Dictionary <string, string> userNames = new Dictionary <string, string>();
            Social.LoadUsers(userIDs.ToArray(), (users) => {
                for (int i = 0; i < users.Length; i++)
                {
                    userNames[users[i].id] = users[i].userName;
                }

                for (int i = 0; i < data.Scores.Length; i++)
                {
                    IScore score    = data.Scores[i];
                    string userName = userNames[score.userID];
                    int rank        = score.rank;

                    fillLeadboard(rank, userName, score.value);
                }

                if (data.NextPageToken != null && container.transform.childCount < 100)
                {
                    LoadMoreScores(data.NextPageToken);
                }
            });
        });
    }
Ejemplo n.º 16
0
 public void LoadMoreScores(ScorePageToken token, int rowCount, Action <LeaderboardScoreData> callback)
 {
     this.GameServices().LeaderboardManager().LoadScorePage((LeaderboardScoreData)null, rowCount, token, callback);
 }
 public void GetNextScorePage(ScorePageToken nextPageToken, Action <LeaderboardScoreData> callback,
                              int rowCount = 10)
 {
     PlayGamesPlatform.Instance.LoadMoreScores(nextPageToken, rowCount, callback);
 }
Ejemplo n.º 18
0
 internal void HandleFetchScoreSummary(LeaderboardScoreData data, FetchScoreSummaryResponse response, string selfPlayerId, int maxResults, ScorePageToken token, Action <LeaderboardScoreData> callback)
 {
     if (response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID && response.GetStatus() != CommonErrorStatus.ResponseStatus.VALID_BUT_STALE)
     {
         Logger.w("Error returned from fetchScoreSummary: " + (object)response);
         data.Status = (GooglePlayGames.BasicApi.ResponseStatus)response.GetStatus();
         callback(data);
     }
     else
     {
         NativeScoreSummary scoreSummary = response.GetScoreSummary();
         data.ApproximateCount = scoreSummary.ApproximateResults();
         data.PlayerScore      = (IScore)scoreSummary.LocalUserScore().AsScore(data.Id, selfPlayerId);
         if (maxResults <= 0)
         {
             callback(data);
         }
         else
         {
             this.LoadScorePage(data, maxResults, token, callback);
         }
     }
 }
 public void LoadMoreScores(ScorePageToken token, int rowCount, System.Action <LeaderboardScoreData> callback)
 {
     throw new System.NotImplementedException();
 }
Ejemplo n.º 20
0
 internal void HandleFetch(ScorePageToken token, FetchResponse response, string selfPlayerId, int maxResults, Action <LeaderboardScoreData> callback)
 {
Ejemplo n.º 21
0
 internal void HandleFetch(ScorePageToken token, GooglePlayGames.Native.PInvoke.FetchResponse response, string selfPlayerId, int maxResults, Action <LeaderboardScoreData> callback)
 {
 public virtual void LoadMoreScores(ScorePageToken token, int rowCount,
                                    Action <LeaderboardScoreData> callback)
 {
     throw new NotSupportedException("unsupported");
 }