public virtual async Task <ActionResult> Index() { var leaderboardCollection = await LeaderboardCollection.GetLeaderboardAsync(); var leaderboardIndexViewModel = new LeaderboardIndexViewModel(); var allBadges = await BadgeCollection.GetAllBadgesByTypeAsync(BadgeType.Unset); leaderboardIndexViewModel.TopTenCorporateBadgeHolders = leaderboardCollection .OrderByDescending(li => li.EarnedCorporateBadgeCount) .Take(10); leaderboardIndexViewModel.TopTenCommunityBadgeHolders = leaderboardCollection .OrderByDescending(li => li.EarnedCommunityBadgeCount) .Take(10); leaderboardIndexViewModel.TotalCorporateBadgeCount = allBadges .Where(bi => bi.Type == BadgeType.Corporate) .Count(); leaderboardIndexViewModel.TotalCommunityBadgeCount = allBadges .Where(bi => bi.Type == BadgeType.Community) .Count(); return(View(leaderboardIndexViewModel)); }
internal ScorePageToken(object internalObject, string id, LeaderboardCollection collection, LeaderboardTimeSpan timespan) { this.mInternalObject = internalObject; this.mId = id; this.mCollection = collection; this.mTimespan = timespan; }
/// <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); }
/// <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)); }
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"); }
internal ScorePageToken(object internalObject, string id, LeaderboardCollection collection, LeaderboardTimeSpan timespan) { mInternalObject = internalObject; mId = id; mCollection = collection; mTimespan = timespan; }
private LeaderboardScoreData CreateLeaderboardScoreData( string leaderboardId, LeaderboardCollection collection, LeaderboardTimeSpan timespan, ResponseStatus status, AndroidJavaObject leaderboardScoresJava) { LeaderboardScoreData leaderboardScoreData = new LeaderboardScoreData(leaderboardId, status); var scoresBuffer = leaderboardScoresJava.Call <AndroidJavaObject>("getScores"); int count = scoresBuffer.Call <int>("getCount"); for (int i = 0; i < count; ++i) { using (var leaderboardScore = scoresBuffer.Call <AndroidJavaObject>("get", i)) { long timestamp = leaderboardScore.Call <long>("getTimestampMillis"); System.DateTime date = AndroidJavaConverter.ToDateTime(timestamp); ulong rank = (ulong)leaderboardScore.Call <long>("getRank"); string scoreHolderId = ""; using (var scoreHolder = leaderboardScore.Call <AndroidJavaObject>("getScoreHolder")) { scoreHolderId = scoreHolder.Call <string>("getPlayerId"); } ulong score = (ulong)leaderboardScore.Call <long>("getRawScore"); string metadata = leaderboardScore.Call <string>("getScoreTag"); leaderboardScoreData.AddScore(new PlayGamesScore(date, leaderboardId, rank, scoreHolderId, score, metadata)); } } leaderboardScoreData.NextPageToken = new ScorePageToken(scoresBuffer, leaderboardId, collection, timespan, ScorePageDirection.Forward); leaderboardScoreData.PrevPageToken = new ScorePageToken(scoresBuffer, leaderboardId, collection, timespan, ScorePageDirection.Backward); using (var leaderboard = leaderboardScoresJava.Call <AndroidJavaObject>("getLeaderboard")) using (var variants = leaderboard.Call <AndroidJavaObject>("getVariants")) using (var variant = variants.Call <AndroidJavaObject>("get", 0)) { leaderboardScoreData.Title = leaderboard.Call <string>("getDisplayName"); if (variant.Call <bool>("hasPlayerInfo")) { System.DateTime date = AndroidJavaConverter.ToDateTime(0); ulong rank = (ulong)variant.Call <long>("getPlayerRank"); ulong score = (ulong)variant.Call <long>("getRawPlayerScore"); string metadata = variant.Call <string>("getPlayerScoreTag"); leaderboardScoreData.PlayerScore = new PlayGamesScore(date, leaderboardId, rank, mUser.id, score, metadata); } leaderboardScoreData.ApproximateCount = (ulong)variant.Call <long>("getNumScores"); } return(leaderboardScoreData); }
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) { GameServices().LeaderboardManager().LoadLeaderboardData( leaderboardId, start, rowCount, collection, timeSpan, this.mUser.id, callback ); }
internal ScorePageToken(object internalObject, string id, LeaderboardCollection collection, LeaderboardTimeSpan timespan, ScorePageDirection direction) { mInternalObject = internalObject; mId = id; mCollection = collection; mTimespan = timespan; mDirection = direction; }
// Convert to LeaderboardVariant.java#Collection internal static int ToLeaderboardVariantCollection(LeaderboardCollection collection) { switch (collection) { case LeaderboardCollection.Social: return(1 /* COLLECTION_SOCIAL */); case LeaderboardCollection.Public: default: return(0 /* COLLECTION_PUBLIC */); } }
public virtual async Task <ActionResult> Search(string searchText) { var leaderboardItems = await LeaderboardCollection.SearchLeaderboardAsync(searchText); if (leaderboardItems.Count() == 1) { var leaderboardItem = leaderboardItems.First(); return(RedirectToAction("Show", new { userName = leaderboardItem.EmployeeADName })); } return(View(leaderboardItems)); }
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)); } }
private void FetchLeaderboardFromTop(string id, LeaderboardCollection collection, LeaderboardTimeSpan timeSpan) { if (!userSignedIn) { return; } leaderboardListLoadState = LeaderboardLoadState.LoadingValues; leaderboardCurPage = 1; leaderboardPageCount = 1; SetLeaderboardListLoading(true); PlayGamesPlatform.Instance.LoadScores(id, LeaderboardStart.TopScores, LEADERBOARD_ENTRIES_PER_PAGE, collection, timeSpan, OnLoadedTopLeaderboards); }
public void GetTopLeaderBoards(string leaderboardId, int rowcount, Action <LeaderboardScoreData> OnFetched, LeaderboardCollection collection = LeaderboardCollection.Public, LeaderboardTimeSpan timeSpan = LeaderboardTimeSpan.AllTime) { if (IsSignedIn()) { PlayGamesPlatform.Instance.LoadScores(leaderboardId, LeaderboardStart.TopScores, rowcount, collection, timeSpan, (data) => { OnFetched(data); }); } }
private void getUserScore(LeaderboardCollection collection, LeaderboardTimeSpan interval) { #if UNITY_ANDROID PlayGamesPlatform.Instance.LoadScores(GPGSIds.leaderboard_magnet_balls_pro, LeaderboardStart.PlayerCentered, 1, collection, interval, (data) => { if (data.Scores.Length > 0) { if (UserScoreInited != null) { UserScoreInited(data.PlayerScore, collection, interval); } } } ); #endif }
public void OnNewLeaderboardCollection() { LeaderboardCollection newCollection = (LeaderboardCollection)(leaderboardCollection.selectionIndex + 1); // Enum starts at 1. if (leaderboardCollectionSetting == newCollection) { return; // No need to refresh if the setting didn't change. } leaderboardCollectionSetting = newCollection; if (!userSignedIn || leaderboardIsLoading || leaderboardData == null) { return; } ReloadCurrentLeaderboard(); }
///<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)); }); } } }
// Initialize Play Services variables upon login. private void InitializeServicesVariables() { if (initPlayServices) { return; } initPlayServices = true; highestSubmittedScores = new Dictionary <string, long>(); leaderboardData = null; curLeaderboardIndex = 0; leaderboardListLoadState = LeaderboardLoadState.DoneLoading; leaderboardUserLoadState = LeaderboardLoadState.DoneLoading; leaderboardCollectionSetting = LeaderboardCollection.Public; leaderboardTimeSpanSetting = LeaderboardTimeSpan.AllTime; // Initialize data instances for each entry in a page. leaderboardResults = new LeaderboardResult[LEADERBOARD_ENTRIES_PER_PAGE]; leaderboardListUi = new LeaderboardItemUI[LEADERBOARD_ENTRIES_PER_PAGE]; leaderboardPageCount = 0; curUserFilter = new string[1] { PlayGamesPlatform.Instance.localUser.id }; // Configure dropdowns for leaderboards. leaderboardTimeFrame.ForceItems("Today", "This Week", "All Time"); leaderboardCollection.ForceItems("Global", "Friends"); leaderboardTimeFrame.SelectItem(2); // All Time. leaderboardCollection.SelectItem(0); // Global. for (int i = 0; i < LEADERBOARD_ENTRIES_PER_PAGE; i++) { leaderboardResults[i] = new LeaderboardResult(); leaderboardListUi[i] = SetupLeaderboardListItem(leaderboardListStart); leaderboardListUi[i].cachedGo.SetActive(false); } curUserLeaderboardItem = SetupLeaderboardListItem(leaderboardCurPlayerStart); curUserLeaderboardItem.cachedGo.SetActive(false); }
private void Main_UserScoreInited(IScore score, LeaderboardCollection collection, LeaderboardTimeSpan interval) { int best = (int)score.value; switch (interval) { case LeaderboardTimeSpan.Daily: PlayGameServiceManager.GetUserScore(LeaderboardCollection.Public, LeaderboardTimeSpan.Weekly); GameData.DailyBest = best; GameData.DailyRank = score.rank; if (DailyScoreInited != null) { DailyScoreInited(score); } break; case LeaderboardTimeSpan.Weekly: PlayGameServiceManager.GetUserScore(LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime); GameData.WeeklyBest = best; GameData.WeeklyRank = score.rank; if (WeeklyScoreInited != null) { WeeklyScoreInited(score); } break; case LeaderboardTimeSpan.AllTime: GameData.OverallBest = best; GameData.OverallRank = score.rank; if (OverallScoreInited != null) { OverallScoreInited(score); } break; } }
/// <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 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)); }
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 static void GetUserScore(LeaderboardCollection collection, LeaderboardTimeSpan interval) { main.getUserScore(collection, interval); }
/// <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)); } }