public void UpdateHighScore()
        {
            currentLeaderBoard.LoadScores((scoreArray, error) => {
                if (error == null)
                {
                    long personalBest;
                    if (currentLeaderBoard.LocalPlayerScore != null)
                    {
                        personalBest = currentLeaderBoard.LocalPlayerScore.Value;
                    }
                    else
                    {
                        personalBest = 0;
                    }
                    playerBestScoreTextField.Text = personalBest.ToString();
                    Console.WriteLine(currentLeaderBoard.Title);

                    var scores = currentLeaderBoard.Scores;
                    if (scores != null && scores.Length > 0)
                    {
                        globalHighestScoreTextField.Text = currentLeaderBoard.Scores [0].Value.ToString();
                    }
                }
                else
                {
                    playerBestScoreTextField.Text    = "Unavailable";
                    globalHighestScoreTextField.Text = "Unavailable";
                }
            });
        }
 public void updateHighScore()
 {
     currentLeaderBoard.LoadScores(new GKScoresLoadedHandler(delegate(GKScore[] scoreArray, NSError error) {
         if (error == null)
         {
             long personalBest;
             if (currentLeaderBoard.LocalPlayerScore != null)
             {
                 personalBest = currentLeaderBoard.LocalPlayerScore.Value;
             }
             else
             {
                 personalBest = 0;
             }
             playerBestScoreTextField.Text = personalBest.ToString();
             if (currentLeaderBoard.Scores.Length > 0)
             {
                 globalHighestScoreTextField.Text = currentLeaderBoard.Scores [0].Value.ToString();
             }
         }
         else
         {
             playerBestScoreTextField.Text    = "Unavailable";
             globalHighestScoreTextField.Text = "Unavailable";
         }
     }));
 }
Exemplo n.º 3
0
    void RetrieveTopTenScores()
    {
        GKLeaderboard leaderboardRequest = new GKLeaderboard();

        if (leaderboardRequest != null)
        {
            // configure request
            leaderboardRequest.playerScope = GKLeaderboardPlayerScope.Global;
            leaderboardRequest.timeScope   = GKLeaderboardTimeScope.AllTime;
            leaderboardRequest.category    = leaderboardID;
            Log("Getting leaderboard identifier: " + leaderboardRequest.identifier);
            Log("Getting leaderboard category: " + leaderboardRequest.category);
            Log("Getting leaderboard group identifier: " + leaderboardRequest.groupIdentifier);
            leaderboardRequest.range = new NSRange(1, 10);

            // load scores; it calls delegate back when done
            leaderboardRequest.LoadScores(delegate(object[] scores, NSError error) {
                if (error != null)
                {
                    Log("Error retrieving scores: " + error.LocalizedDescription());
                }
                else if (scores != null)
                {
                    // got the scores, but the low-level GKScore only has player ID.
                    // if you want player display name, you need to combine it with
                    // the high-level API to load the players
                    string[] playerIDs = scores.Cast <GKScore>().Select(x => x.playerID).ToArray();
                    Player.LoadPlayersByIDs(playerIDs, delegate(Player[] players) {
                        // print localized title of leaderboard
                        Log("Top 10 for " + leaderboardRequest.title);

                        for (int i = 0; i < scores.Length; i++)
                        {
                            GKScore score = scores[i] as GKScore;

                            result += score.formattedValue + System.Environment.NewLine;

                            Player player = players[i];
                            Log(score.rank + ". " + score.formattedValue + ", " + score.date + ", " + player.displayName);
                        }
                    });
                }
            });
        }
    }
Exemplo n.º 4
0
    void RetrieveTopTenScores()
    {
        GKLeaderboard leaderboardRequest = new GKLeaderboard();
        if (leaderboardRequest != null) {
            // configure request
            leaderboardRequest.playerScope = GKLeaderboardPlayerScope.Global;
            leaderboardRequest.timeScope = GKLeaderboardTimeScope.AllTime;
            leaderboardRequest.category = leaderboardID;
            leaderboardRequest.range = new NSRange(1, 10);

            // load scores; it calls delegate back when done
            leaderboardRequest.LoadScores(delegate(object[] scores, NSError error) {
                if (error != null) {
                    Log("Error retrieving scores: " + error.LocalizedDescription());
                } else if (scores != null) {

                    // got the scores, but the low-level GKScore only has player ID.
                    // if you want player display name, you need to combine it with
                    // the high-level API to load the players
                    string[] playerIDs = scores.Cast<GKScore>().Select(x => x.playerID).ToArray();
                    Player.LoadPlayersByIDs(playerIDs, delegate(Player[] players) {

                        // print localized title of leaderboard
                        Log("Top 10 for " + leaderboardRequest.title);

                        for (int i=0; i<scores.Length; i++) {
                            GKScore score = scores[i] as GKScore;
                            Player player = players[i];
                            Log(score.rank + ". " + score.formattedValue + ", " + score.date + ", " + player.displayName);
                        }
                    });
                }
            });
        }
    }
Exemplo n.º 5
0
    public void RetrieveTopTenScores()
    {
                #if UNITY_IOS && !UNITY_EDITOR
        GKLeaderboard leaderboardRequest = new GKLeaderboard();
        if (leaderboardRequest != null)
        {
            // configure request
            leaderboardRequest.playerScope = GKLeaderboardPlayerScope.Global;
            leaderboardRequest.timeScope   = GKLeaderboardTimeScope.AllTime;
            leaderboardRequest.category    = leaderboardID;
            leaderboardRequest.range       = new NSRange(1, 1);
            // load scores; it calls delegate back when done
            leaderboardRequest.LoadScores(delegate(object[] scores, NSError error) {
                if (error != null)
                {
                    //Log("Error retrieving scores: " + error.LocalizedDescription());
                }
                else if (scores != null)
                {
                    // got the scores, but the low-level GKScore only has player ID.
                    // if you want player display name, you need to combine it with
                    // the high-level API to load the players
                    string[] playerIDs = scores.Cast <GKScore>().Select(x => x.playerID).ToArray();
                    Player.LoadPlayersByIDs(playerIDs, delegate(Player[] players) {
                        // print localized title of leaderboard
                        //Log("Top 100 for " + leaderboardRequest.title);


                        //current user
                        GKScore score = leaderboardRequest.localPlayerScore;
                        int rank      = score.rank;
                        Player player = players[0];

                        //GameObject.Find ("TESTE").transform.GetChild(0).GetComponent<Text>().text="rank "+rank+" Score "+score+" Name "+player.displayName;

                        //All scores

                        /*for (int i=0; i<scores.Length; i++) {
                         *      GKScore score = scores[i] as GKScore;
                         *      Player player = players[i];
                         *      //plname = players[i];
                         *      testescore+=score.rank + ". " + score.formattedValue +", "+player.displayName;
                         *      //testescore+=score.rank + ". " + score.formattedValue;
                         *      //GameObject.Find ("TESTE").transform.GetChild(0).GetComponent<Text>().text="ShowScore "+testescore;
                         *      Debug.Log(score.rank + ". " + score.formattedValue + ", " + score.date + ", " + player.displayName);
                         * }*/
                    });
                }
            });
        }
                #endif

                #if UNITY_ANDROID && !UNITY_EDITOR
        /*ILeaderboard lb = Social.CreateLeaderboard();
         * lb.id = leaderboardID;
         * lb.LoadScores(ok =>
         *            {
         *      if (ok) {
         *              androidstatus="OK retrieving leaderboard";
         *              LoadUsersAndDisplay(lb);
         *      }
         *      else {
         *              androidstatus="Error retrieving leaderboard";
         *      }
         * });*/
                #endif
    }
Exemplo n.º 6
0
        public override void GetBestScoreAndRank(GameMode mode, GameDifficulty difficulty, Action<int,int> gcRankCallback)
        {
            if (IsAuthenticated)
              {

            if (gcRankCallback != null)
            {

              string leaderboardId = GetLeaderboardId(mode, difficulty);
              GKLeaderboard leaderboard = new GKLeaderboard();
              leaderboard.GroupIdentifier = leaderboardId;

              leaderboard.LoadScores((scoreArray, error) => {

            if (leaderboard.LocalPlayerScore != null)
            {
              int bestScore = (int) leaderboard.LocalPlayerScore.Value;
              int bestRank = leaderboard.LocalPlayerScore.Rank;

              gcRankCallback(bestRank, bestScore);
            }
              });

            }
              }
        }