public void ReportTime(float time) { #if UNITY_IOS ISN_GKScore scoreReporter = new ISN_GKScore(IOS_TIME_LEADERBOARD_ID); scoreReporter.Value = (long)time * 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); } }); #elif UNITY_ANDROID Social.ReportScore((long)time, "CgkI8fqhh7oYEAIQAg", (bool success) => { // handle success or failure }); #endif if (time > BestTime) { BestTime = time; } }
public void ReportScore(int score) { #if UNITY_IOS ISN_GKScore scoreReporter = new ISN_GKScore(IOS_SCORE_LEADERBOARD_ID); scoreReporter.Value = score; 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); } }); #elif UNITY_ANDROID Social.ReportScore(score, "CgkI8fqhh7oYEAIQAQ", (bool success) => { // handle success or failure }); #endif if (score > HighScore) { HighScore = score; } }
public void ReportAcorns(int acorns) { #if UNITY_IOS ISN_GKScore scoreReporter = new ISN_GKScore(IOS_ACORNS_LEADERBOARD_ID); scoreReporter.Value = acorns; 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); } }); #elif UNITY_ANDROID Social.ReportScore(acorns, "CgkI8fqhh7oYEAIQAw", (bool success) => { // handle success or failure }); #endif Acorns = acorns; }
/// <summary> /// Report leaderboard data /// </summary> /// <param name="leaderboardId"></param> /// <param name="incrementalData"></param> /// <param name="leaderboardName"></param> public void SubmitLeaderboardData(string leaderboardId, int incrementalData, [CanBeNull] string leaderboardName = null) { if (GCenterLoginHelper.Instance.IsSignedIn() && _isInitialized) { var scoreReporter = new ISN_GKScore(leaderboardId) { Value = incrementalData, Context = 1 }; scoreReporter.Report(result => { if (result.IsSucceeded) { Debug.Log("Leaderboard Submit -> " + (leaderboardName ?? leaderboardId) + ", value: " + incrementalData); } else { Debug.Log("Score Report failed! Code: " + result.Error.Code + " Message: " + result.Error.Message); } }); } }
public void SubmitScore(string leaderboardId, long score, int context, Action <SA_Result> callback) { ISN_GKScore scoreReporter = new ISN_GKScore(leaderboardId); scoreReporter.Value = score; scoreReporter.Context = context; scoreReporter.Report((result) => { ReportScoreSubmited(leaderboardId, score, result); callback.Invoke(result); }); }
public override void OnLeaderboardReady(ISN_GKLeaderboard leaderboard) { ISN_Logger.Log("leaderboard.LocalPlayerScore.Rank: " + leaderboard.LocalPlayerScore.Rank); ISN_Logger.Log("leaderboard.LocalPlayerScore.Value: " + leaderboard.LocalPlayerScore.Value); ISN_GKScore scoreReporter = new ISN_GKScore(leaderboard.Identifier); scoreReporter.Value = leaderboard.LocalPlayerScore.Value++; scoreReporter.Context = 1; scoreReporter.Report((result) => { 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); * } * }); */ }