Пример #1
0
    /// <summary>
    /// Gets the leadboard on level.
    /// </summary>
    public void GetLeadboardOnLevel(int LevelNumber, Action <List <LeadboardPlayerData> > Callback)
    {
        PlayFab.ClientModels.GetFriendLeaderboardAroundPlayerRequest request = new PlayFab.ClientModels.GetFriendLeaderboardAroundPlayerRequest()
        {
            StatisticName          = "Level_" + LevelNumber,
            MaxResultsCount        = 5,
            PlayFabId              = NetworkManager.UserID,
            IncludeFacebookFriends = true
        };

        PlayFabClientAPI.GetFriendLeaderboardAroundPlayer(request, (result) => {
            if (LevelManager.THIS.gameStatus == GameState.Map)
            {
                NetworkManager.leadboardList.Clear();
            }
            List <LeadboardPlayerData> list = new List <LeadboardPlayerData> ();
            foreach (var item in result.Leaderboard)
            {
                LeadboardPlayerData pl = new LeadboardPlayerData();
                pl.Name     = item.DisplayName;
                pl.userID   = item.PlayFabId;
                pl.position = item.Position;
                pl.score    = item.StatValue;

                list.Add(pl);
                Debug.Log(item.DisplayName + " " + item.PlayFabId + " " + item.Position + " " + item.StatValue);
            }
            Callback(list);
        }, (error) => {
            Debug.Log(error.ErrorDetails);
        });
    }
        /// <summary>
        /// Retrieves a list of ranked friends of the current player for the given statistic, centered on the requested PlayFab user. If PlayFabId is empty or null will return currently logged in user.
        /// </summary>
        public static void GetFriendLeaderboardAroundPlayer(GetFriendLeaderboardAroundPlayerRequest request, ProcessApiCallback<GetFriendLeaderboardAroundPlayerResult> resultCallback, ErrorCallback errorCallback, object customData = null)
        {
            if (_authKey == null) throw new Exception("Must be logged in to call this method");

            string serializedJson = SimpleJson.SerializeObject(request, Util.ApiSerializerStrategy);
            Action<CallRequestContainer> callback = delegate(CallRequestContainer requestContainer)
            {
                ResultContainer<GetFriendLeaderboardAroundPlayerResult>.HandleResults(requestContainer, resultCallback, errorCallback, null);
            };
            PlayFabHTTP.Post("/Client/GetFriendLeaderboardAroundPlayer", serializedJson, "X-Authorization", _authKey, callback, request, customData);
        }