예제 #1
0
        private void RequestLeaderboard()
        {
            if (IsInternetConnected() && NetworkManager.Instance.IsAuthenticated)
            {
                Log.Info("RequestLeaderboard()");
                LeaderboardDataRequestData req = new LeaderboardDataRequestData();
                req.entryCount           = 10;
                req.LeaderboardShortCode = GameConst.LEADERBOARD_SHORTCODE;

                NetworkManager.Instance.GSRequestLeaderboard(req);
            }
        }
예제 #2
0
        /// <summary>
        /// Request leaderboard
        /// </summary>
        /// <param name="request"></param>
        public void GSRequestLeaderboard(LeaderboardDataRequestData request)
        {
            Log.Info("GSRequestLeaderboard");

            LeaderboardDataRequest req = new LeaderboardDataRequest();

            req.SetLeaderboardShortCode(request.LeaderboardShortCode);
            req.SetEntryCount(request.entryCount);

            req.Send(response =>
            {
                if (response.HasErrors)
                {
                    Debug.LogWarning("Error in GSRequestLeaderboard()");
                    Debug.Log("Error: " + response.Errors.JSON);
                }
                else
                {
                    Debug.Log("GSRequestLeaderboard() succeed");
                    Debug.Log(response.JSONString);

                    var data = response.Data;

                    List <RankData> listModel = new List <RankData>();

                    foreach (var item in data)
                    {
                        Debug.Log(item.JSONString);
                        RankData rankModel = new RankData(item.UserId, (int)item.GetNumberValue("SCORE"),
                                                          item.When, item.City, item.Country, item.UserName, item.ExternalIds, (int)item.Rank);
                        Log.Info(rankModel.ToString());

                        listModel.Add(rankModel);
                    }

                    GameManager.Instance.ListGlobalRankData = listModel;

                    this.PostEvent(EventID.OnRequestLeaderboardDone);
                }
            });
        }