public void Initialization(Action resultCallback = null)
        {
            if (!_isInitialized)
            {
                ISN_GKLeaderboard.LoadLeaderboards(result =>
                {
                    if (result.IsSucceeded)
                    {
                        foreach (var leaderboard in result.Leaderboards)
                        {
                            Debug.Log("Leaderboard.ID: " + leaderboard.Identifier);
                            Debug.Log("Leaderboard.GroupID: " + leaderboard.GroupIdentifier);
                            Debug.Log("Leaderboard.Title: " + leaderboard.Title);
                        }

                        _isInitialized  = true;
                        _viewController = new ISN_GKGameCenterViewController();
                        resultCallback.SafeInvoke();
                    }
                    else
                    {
                        Debug.Log("Load Leaderboards failed! Error code: " + result.Error.Code + ", Message: " +
                                  result.Error.Message);

                        _isInitialized  = false;
                        _viewController = null;
                    }
                });
            }
        }
 public override void Test()
 {
     ISN_GKLeaderboard.LoadLeaderboards((result) => {
         if (result.IsSucceeded && result.Leaderboards.Count > 0)
         {
             OnLeaderboardReady(result.Leaderboards[0]);
         }
         else
         {
             SetResult(SA_TestResult.WithError("Wasn't able to find leaderboards"));
         }
     });
 }
 public void LoadLeaderboardsMetadata(Action <UM_LoadLeaderboardsMetaResult> callback)
 {
     ISN_GKLeaderboard.LoadLeaderboards((result) => {
         UM_LoadLeaderboardsMetaResult um_result;
         if (result.IsSucceeded)
         {
             List <UM_iLeaderboard> um_leaderboards = new List <UM_iLeaderboard>();
             foreach (var leaderboards in result.Leaderboards)
             {
                 var um_leaderboardMetda = new UM_LeaderboardMeta(leaderboards.Identifier, leaderboards.Title);
                 um_leaderboards.Add(um_leaderboardMetda);
             }
             um_result = new UM_LoadLeaderboardsMetaResult(um_leaderboards);
         }
         else
         {
             um_result = new UM_LoadLeaderboardsMetaResult(result.Error);
         }
         callback.Invoke(um_result);
     });
 }
Beispiel #4
0
        public override void Test()
        {
            ISN_GKLeaderboard.LoadLeaderboards((result) => {
                if (result.IsSucceeded)
                {
                    if (result.Leaderboards.Count == 0)
                    {
                        SetResult(SA_TestResult.WithError("No leaderboards inside the Sucsses result"));
                        return;
                    }

                    foreach (var leaderboards in result.Leaderboards)
                    {
                        ISN_Logger.Log(leaderboards.Identifier);
                        ISN_Logger.Log(leaderboards.GroupIdentifier);
                        ISN_Logger.Log(leaderboards.Title);
                    }
                }

                SetAPIResult(result);
            });
        }
Beispiel #5
0
        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);
             *  }
             * });
             */
        }