public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = leaderboardId; var isn_timeSpan = ToIOSSpan(span); var isn_collection = ToIOSCollection(collection); leaderboardRequest.PlayerScope = isn_collection; leaderboardRequest.TimeScope = isn_timeSpan; leaderboardRequest.Range = new ISN_NSRange(1, 1); leaderboardRequest.LoadScores(result => { UM_ScoreLoadResult um_result; if (result.IsSucceeded) { var score = new UM_Score(leaderboardRequest.LocalPlayerScore.Value, leaderboardRequest.LocalPlayerScore.Rank, (int)leaderboardRequest.LocalPlayerScore.Context, leaderboardRequest.LocalPlayerScore.DateUnix); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(result.Error); } callback.Invoke(um_result); }); }
public override void OnLeaderboardReady(ISN_GKLeaderboard leaderboard) { var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = leaderboard.Identifier; leaderboardRequest.PlayerScope = ISN_GKLeaderboardPlayerScope.Global; leaderboardRequest.TimeScope = ISN_GKLeaderboardTimeScope.AllTime; leaderboardRequest.Range = new ISN_NSRange(1, 10); leaderboardRequest.LoadScores((result) => { if (result.IsSucceeded) { ISN_Logger.Log("Score Load Success"); foreach (var score in result.Scores) { ISN_Logger.Log("score.Value: " + score.Value); ISN_Logger.Log("score.Context: " + score.Context); ISN_Logger.Log("score.Date: " + score.Date); ISN_Logger.Log("score.Rank: " + score.Rank); ISN_Logger.Log("score.Player.PlayerID: " + score.Player.PlayerID); ISN_Logger.Log("score.Player.DisplayName: " + score.Player.DisplayName); ISN_Logger.Log("score.Player.Alias: " + score.Player.Alias); } ISN_Logger.Log("leaderboardRequest.MaxRange: " + leaderboardRequest.MaxRange); ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Value: " + leaderboardRequest.LocalPlayerScore.Value); ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Context: " + leaderboardRequest.LocalPlayerScore.Context); ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Date: " + leaderboardRequest.LocalPlayerScore.Date); ISN_Logger.Log("leaderboardRequest.LocalPlayerScore.Rank: " + leaderboardRequest.LocalPlayerScore.Rank); } SetAPIResult(result); }); }
void Awake() { ISN_GKLocalPlayerListener.DidModifySavedGame.AddListener(DidModifySavedGame); ISN_GKLocalPlayerListener.HasConflictingSavedGames.AddListener(HasConflictingSavedGames); ISN_GKAchievement.LoadAchievements((result) => { if (result.IsSucceeded) { foreach (ISN_GKAchievement achievement in result.Achievements) { Debug.Log(achievement.Identifier); Debug.Log(achievement.PercentComplete); Debug.Log(achievement.LastReportedDate); Debug.Log(achievement.Completed); } } else { Debug.Log("LoadAchievements failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); ISN_GKAchievement.ResetAchievements((result) => { if (result.IsSucceeded) { Debug.Log("Reset Achievements Success"); } else { Debug.Log("Reset Achievements failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); ISN_GKGameCenterViewController viewController = new ISN_GKGameCenterViewController(); viewController.ViewState = ISN_GKGameCenterViewControllerState.Leaderboards; viewController.Show(); ISN_GKScore scoreReporter = new ISN_GKScore("itunes.leaderboard.id"); scoreReporter.Value = 100; scoreReporter.Context = 1; scoreReporter.Report((result) => { if (result.IsSucceeded) { Debug.Log("Score Report Success"); } else { Debug.Log("Score Report failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); ISN_GKScore scoreReporter1 = new ISN_GKScore("itunes.leaderboard.id.1"); scoreReporter1.Value = 100; scoreReporter1.Context = 1; ISN_GKScore scoreReporter2 = new ISN_GKScore("itunes.leaderboard.id.2"); scoreReporter2.Value = 100; scoreReporter2.Context = 1; var scores = new List <ISN_GKScore>() { scoreReporter1, scoreReporter2 }; ISN_GKScore.ReportScores(scores, (result) => { if (result.IsSucceeded) { Debug.Log("Score Report Success"); } else { Debug.Log("Score Report failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = "itunes.leaderboard.id"; leaderboardRequest.PlayerScope = ISN_GKLeaderboardPlayerScope.Global; leaderboardRequest.TimeScope = ISN_GKLeaderboardTimeScope.AllTime; leaderboardRequest.Range = new ISN_NSRange(1, 10); leaderboardRequest.LoadScores((result) => { if (result.IsSucceeded) { Debug.Log("Score Load Success"); foreach (var score in result.Scores) { Debug.Log(score.Value); Debug.Log(score.Context); Debug.Log(score.Date); Debug.Log(score.Rank); Debug.Log(score.Player.PlayerID); Debug.Log(score.Player.DisplayName); Debug.Log(score.Player.Alias); } Debug.Log(leaderboardRequest.MaxRange); Debug.Log(leaderboardRequest.LocalPlayerScore.Value); Debug.Log(leaderboardRequest.LocalPlayerScore.Context); Debug.Log(leaderboardRequest.LocalPlayerScore.Date); Debug.Log(leaderboardRequest.LocalPlayerScore.Rank); } else { Debug.Log("Score Load failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); ISN_GKLeaderboard.LoadLeaderboards((result) => { if (result.IsSucceeded) { foreach (var leaderboards in result.Leaderboards) { Debug.Log(leaderboards.Identifier); Debug.Log(leaderboards.GroupIdentifier); Debug.Log(leaderboards.Title); } } else { Debug.Log("Load Leaderboards failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); /* * * ISN_GKAchievement achievement = new ISN_GKAchievement("itunes.achievement.id"); * achievement.PercentComplete = 50.0f; * achievement.Report((result) => { * if(result.IsSucceeded) { * Debug.Log("Achievement reported"); * } else { * Debug.Log("Achievement report failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); * } * }); * * * ISN_GKAchievement achievement1 = new ISN_GKAchievement("itunes.achievement.id.1"); * achievement.PercentComplete = 50.0f; * * ISN_GKAchievement achievement2 = new ISN_GKAchievement("itunes.achievement.id.2"); * achievement.PercentComplete = 70.0f; * * var achievements = new List<ISN_GKAchievement>() { achievement1, achievement2 }; * * ISN_GKAchievement.ReportAchievements(achievements, (result) => { * if (result.IsSucceeded) { * Debug.Log("Achievements reported"); * } else { * Debug.Log("Achievements report failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); * } * }); */ }
public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback) { var leaderboardRequest = new ISN_GKLeaderboard(); leaderboardRequest.Identifier = leaderboardId; ISN_GKLeaderboardPlayerScope isn_collection = ISN_GKLeaderboardPlayerScope.Global; switch (collection) { case UM_LeaderboardCollection.Public: isn_collection = ISN_GKLeaderboardPlayerScope.Global; break; case UM_LeaderboardCollection.Social: isn_collection = ISN_GKLeaderboardPlayerScope.FriendsOnly; break; } ISN_GKLeaderboardTimeScope isn_timeSpan = ISN_GKLeaderboardTimeScope.AllTime; switch (span) { case UM_LeaderboardTimeSpan.AllTime: isn_timeSpan = ISN_GKLeaderboardTimeScope.AllTime; break; case UM_LeaderboardTimeSpan.Weekly: isn_timeSpan = ISN_GKLeaderboardTimeScope.Week; break; case UM_LeaderboardTimeSpan.Daily: isn_timeSpan = ISN_GKLeaderboardTimeScope.Today; break; } leaderboardRequest.PlayerScope = isn_collection; leaderboardRequest.TimeScope = isn_timeSpan; leaderboardRequest.Range = new ISN_NSRange(1, 1); leaderboardRequest.LoadScores((result) => { UM_ScoreLoadResult um_result; if (result.IsSucceeded) { UM_Score score = new UM_Score(leaderboardRequest.LocalPlayerScore.Value, leaderboardRequest.LocalPlayerScore.Rank, (int)leaderboardRequest.LocalPlayerScore.Context, leaderboardRequest.LocalPlayerScore.DateUnix); um_result = new UM_ScoreLoadResult(score); } else { um_result = new UM_ScoreLoadResult(result.Error); } callback.Invoke(um_result); }); }