public void GetScoreLeaderboard(UnityAction <ScoreBoardList> callback) { var list = new ScoreBoardList(); var request = new GetLeaderboardAroundPlayerRequest { StatisticName = Globals.PLAYFAB_SCORE_KEY }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, result => { if (callback != null) { foreach (var item in result.Leaderboard) { list.Add(new GameController.ScoreBoardEntry( item.DisplayName, item.StatValue )); } callback(list); } }, error => { OnNetworkOperationFailure(error); if (callback != null) { callback(list); } }); }
/// <summary> /// /// </summary> /// <param name="count"></param> /// <param name="leaderboardResult"></param> /// <param name="OnFailedToLoad"></param> /// <param name="leaderboardName"></param> public static void GetLeaderboardAroundPlayer(int count, Action <GetLeaderboardAroundPlayerResult> leaderboardResult, Action OnFailedToLoad = null, string leaderboardName = "TotalCurrencyBased_Global") { if (PlayFabClientAPI.IsClientLoggedIn()) { var request = new GetLeaderboardAroundPlayerRequest { StatisticName = "TotalCurrencyBased_Global", MaxResultsCount = count }; request.ProfileConstraints = new PlayerProfileViewConstraints(); request.ProfileConstraints.ShowAvatarUrl = true; request.ProfileConstraints.ShowDisplayName = true; request.ProfileConstraints.ShowLocations = true; request.ProfileConstraints.ShowContactEmailAddresses = true; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, leaderboardResult, op => { if (OnFailedToLoad != null) { OnFailedToLoad(); } }); } }
public static Promise <List <LeaderboardEntry> > GetPlayerLeaderboard(string statisticName, int amount = 0) { var promise = new Promise <List <LeaderboardEntry> >(); var request = new GetLeaderboardAroundPlayerRequest { StatisticName = statisticName }; request.MaxResultsCount = amount == 0 ? Config.maxLeaderboardEntries : amount; request.ProfileConstraints = new PlayerProfileViewConstraints { ShowAvatarUrl = true, ShowLocations = true }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, (result) => { List <LeaderboardEntry> entries = LeaderboardEntriesFromLeaderboard(result.Leaderboard); if (entries != null) { promise.Resolve(entries); GetPlayerLeaderboardSuccessCallback(result); } else { promise.Reject(new Exception("There's a problem with the player leadeboard.")); } }, ErrorCallback); return(promise); }
// 나의 순위 호출 함수 public void GetMyRanking() { GetLeaderboardAroundPlayerRequest request = new GetLeaderboardAroundPlayerRequest(); request.MaxResultsCount = 1; request.StatisticName = "score"; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, GetMyRankingSuccess, OnPlayFabError); }
public void GetLeaderboardAroundPlayer(Leaderboard board, Action <GetLeaderboardAroundPlayerResult> cb, Action <PlayFabError> errorCb, bool previousSeason = false, int maxCount = 1) { GetLeaderboardAroundPlayerRequest request = new GetLeaderboardAroundPlayerRequest { StatisticName = PlayFabLeaderboard.GetBoardName(board, previousSeason), MaxResultsCount = new int?(maxCount) }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, cb, errorCb, null, null); }
/** * Gets leaderboard entries around the user. */ partial void InitialiseUserPartial() { GetLeaderboardAroundPlayerRequest request = new GetLeaderboardAroundPlayerRequest() { StatisticName = m_name, MaxResultsCount = m_maxEntries }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, OnUserSuccess, OnFailure); }
public void GetLeaderboard() { var request = new GetLeaderboardAroundPlayerRequest { StatisticName = "MostWin", MaxResultsCount = 6 }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, OnLeaderboardGet, OnError); }
public static void GetRankings(int index, Action <List <PlayerLeaderboardEntry>, PlayerLeaderboardEntry> callback) { // Reset the list topPlayersList = null; localPlayerRanking = null; var request = new GetLeaderboardRequest { StatisticName = PlayerData.HighScoreKey, StartPosition = 0, MaxResultsCount = 100 }; PlayFabClientAPI.GetLeaderboard(request, result => { topPlayersList = result.Leaderboard; if (topPlayersList != null && localPlayerRanking != null) { callback(topPlayersList, localPlayerRanking); } }, error => { Debug.LogWarning("Something went wrong with GetRankings :("); Debug.LogError(error.GenerateErrorReport()); } ); var localPlayerRequest = new GetLeaderboardAroundPlayerRequest { StatisticName = PlayerData.HighScoreKey, MaxResultsCount = 1, }; PlayFabClientAPI.GetLeaderboardAroundPlayer(localPlayerRequest, result => { localPlayerRanking = result.Leaderboard[0]; if (topPlayersList != null && localPlayerRanking != null) { callback(topPlayersList, localPlayerRanking); } }, error => { Debug.LogWarning("Something went wrong with GetRankings local player :("); Debug.LogError(error.GenerateErrorReport()); } ); }
public static void GetMyPlayerLeaderboardRank(string stat, UnityAction <int> callback = null) { var request = new GetLeaderboardAroundPlayerRequest { StatisticName = stat }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, result => { if (callback != null && result.Leaderboard.Count > 0) { callback(result.Leaderboard.First().Position); } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GetMyPlayerRank, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
/// <summary> /// ランキング取得(自身の周囲) /// </summary> public IEnumerator PlayFabGetLeaderboardAroundPlayer(string stasticName, int maxResultsCount) { var getLeaderBoardFunction = new CustomPlayFabFunction <GetLeaderboardAroundPlayerRequest, GetLeaderboardAroundPlayerResult>(); var request = new GetLeaderboardAroundPlayerRequest { StatisticName = stasticName, MaxResultsCount = maxResultsCount // ランキングデータを何件取得するか 自身を含めた数 +-の範囲はMaxResultsCount/2 }; getLeaderBoardFunction.SetRequest = request; yield return(StartCoroutine(getLeaderBoardFunction.ExecuteCoroutine(PlayFabClientAPI.GetLeaderboardAroundPlayer))); Debug.Log("Result:" + JsonUtility.ToJson(getLeaderBoardFunction.GetResult)); leaderboardEntryList = getLeaderBoardFunction.GetResult.Leaderboard; }
public IEnumerator GetLeaderboardAroundPlayer(string name, int max) { GetLeaderboardAroundPlayerRequest req = new GetLeaderboardAroundPlayerRequest { StatisticName = name, MaxResultsCount = max, ProfileConstraints = new PlayerProfileViewConstraints { ShowDisplayName = true }, }; Action <Action <GetLeaderboardAroundPlayerResult>, Action <PlayFabError> > apiCall = (onsuccess, onError) => { PlayFabClientAPI.GetLeaderboardAroundPlayer(req, onsuccess, onError); }; yield return(ExecuteApiCallWithRetry(apiCall)); }
IEnumerator GetRankingCor(RankKind kind, Action <RankData> onGot) { List <PlayerLeaderboardEntry> top100 = null; var requestTop100 = new GetLeaderboardRequest { StatisticName = kind.ToString(), MaxResultsCount = 100 }; PlayFabClientAPI.GetLeaderboard ( requestTop100, result => top100 = result.Leaderboard, error => Debug.Log(error.GenerateErrorReport()) ); List <PlayerLeaderboardEntry> aroundPlayer100 = null; var requestAroundPlayer = new GetLeaderboardAroundPlayerRequest { StatisticName = kind.ToString(), MaxResultsCount = 100 }; PlayFabClientAPI.GetLeaderboardAroundPlayer ( requestAroundPlayer, result => aroundPlayer100 = result.Leaderboard, error => Debug.Log(error.GenerateErrorReport()) ); yield return(new WaitUntil(() => top100 != null && aroundPlayer100 != null)); onGot.Invoke(new RankData ( kind, top100 .Select(entry => new RankDatum(entry.DisplayName, entry.Position + 1, NumberToTimeFloat(entry.StatValue))) .ToArray(), aroundPlayer100 .Select(entry => new RankDatum(entry.DisplayName, entry.Position + 1, NumberToTimeFloat(entry.StatValue))) .ToArray() )); }
public void GetLeaderboard(string currentLevel) { var request = new GetLeaderboardRequest { StatisticName = currentLevel, StartPosition = 0, MaxResultsCount = 5 }; PlayFabClientAPI.GetLeaderboard(request, OnLeaderboardGet, OnError); var request2 = new GetLeaderboardAroundPlayerRequest { StatisticName = currentLevel, PlayFabId = null, MaxResultsCount = 1 }; PlayFabClientAPI.GetLeaderboardAroundPlayer(request2, OnLeaderboardAroundPlayerGet, OnError); }
public void GetPlayerStats(string playerPlayfabId) { if (playerPlayfabId != null) { GetLeaderboardAroundPlayerRequest request = new GetLeaderboardAroundPlayerRequest(); request.MaxResultsCount = 1; request.PlayFabId = playerPlayfabId; request.ProfileConstraints = new PlayerProfileViewConstraints() { ShowStatistics = true, ShowDisplayName = true, ShowAvatarUrl = true }; request.StatisticName = "Wins"; PlayFabClientAPI.GetLeaderboardAroundPlayer(request, GetPlayerStatsResult, OnPlayFabError); HideFriendList(); PlayerProfileComponent = Instantiate(PlayerProfilePrefab, Camera.main.transform).GetComponent <PlayerProfile> (); PlayerProfileComponent.GetComponent <Canvas> ().worldCamera = Camera.main; } }
private void RequestTheLeaderboard() { try { requestTopLeaderboard = new GetLeaderboardRequest { StartPosition = 0, StatisticName = "Top Scores", MaxResultsCount = 100 }; requestLeaderboardAroundPlayer = new GetLeaderboardAroundPlayerRequest { StatisticName = "Top Scores" }; PlayFabClientAPI.GetLeaderboard(requestTopLeaderboard, OnGetLeaderBoard, OnErrorLeaderboard); loadingAnimation.SetActive(true); PlayFabClientAPI.GetLeaderboardAroundPlayer(requestLeaderboardAroundPlayer, OnGetLeaderBoardAroundPlayer, OnErrorLeaderboard); } catch (Exception ex) { loadingAnimation.SetActive(false); FindObjectOfType <ShowErrorMessageController>().SetErrorMessage(ex.Message); debugReporter.text = debugReporter.text + "\n" + "GetLeaderboard(): Failed with error: " + ex.Message; } }
public async Task <bool> getLeaderboard(int size) { await Task.Delay(500); nearbyPlayersIDs = new string[size]; var request = new GetLeaderboardAroundPlayerRequest { StatisticName = "Ranking", MaxResultsCount = size }; var leaderboardTask = await PlayFabClientAPI.GetLeaderboardAroundPlayerAsync(request); if (leaderboardTask.Error != null) { logError(leaderboardTask.Error.Error.ToString(), leaderboardTask.Error.ErrorMessage); await Task.Delay(1500); return(false); } if (leaderboardTask == null || leaderboardTask.Result == null) { logError("Leaderboard Error", leaderboardTask.Result.ToString()); await Task.Delay(1500); return(false); } else { for (int i = 0; i < size; i++) { nearbyPlayersIDs[i] = leaderboardTask.Result.Leaderboard[i].PlayFabId; if (leaderboardTask.Result.Leaderboard[i].DisplayName == username) { userIndex = i; } } return(true); } }
/// <summary> /// updates the highscore playerpref /// </summary> public void GetHighscore() { FindObjectOfType <GameOverScreenController>().SyncHighscoreWhenOnline(); try { requestLeaderboardAroundPlayer = new GetLeaderboardAroundPlayerRequest { StatisticName = "Top Scores" }; PlayFabClientAPI.GetLeaderboardAroundPlayer(requestLeaderboardAroundPlayer, UpdatePlayerHighscore, UpdatePlayerHighScoreError); } catch (Exception ex) { if (Application.internetReachability != NetworkReachability.NotReachable) { FindObjectOfType <ShowErrorMessageController>().SetErrorMessage("FAILED TO UPDATE HIGHSCORE: " + ex.Message); } else { FindObjectOfType <ShowErrorMessageController>().SetErrorMessage("FOR THE BEST EXPERIENCE YOU SHOULD CONNECT TO THE INTERNET!"); } } }
public static IEnumerator <GetLeaderboardAroundPlayerResult> Do(GetLeaderboardAroundPlayerRequest request) { return(Do <GetLeaderboardAroundPlayerRequest, GetLeaderboardAroundPlayerResult>(request, PlayFabClientAPI.GetLeaderboardAroundPlayer)); }
public static UnityTask <GetLeaderboardAroundPlayerResult> Do(GetLeaderboardAroundPlayerRequest request) { return(Do <GetLeaderboardAroundPlayerRequest, GetLeaderboardAroundPlayerResult>(request, PlayFabClientAPI.GetLeaderboardAroundPlayer)); }