示例#1
0
 public void ResetAchievements()
 {
     if (active)
     {
         GalaxyInstance.Stats().ResetStatsAndAchievements();
     }
 }
        public override void OnLeaderboardEntriesRetrieveSuccess(string leaderboardName, uint entryCount)
        {
            Debug.Log("Leaderboard \"" + leaderboardName + "\" entries retrieved\nEntry count: " + entryCount);

            leaderboardEntries.Clear();
            leaderboardEntries.TrimExcess();

            for (uint i = 0; i < entryCount; i++)
            {
                GalaxyID userID       = new GalaxyID();
                uint     rank         = 0;
                int      score        = 0;
                string   username     = null;
                object[] entryDetails = new object[] { rank, score, username };

                GalaxyInstance.Stats().GetRequestedLeaderboardEntry(i, ref rank, ref score, ref userID);
                username        = GalaxyManager.Instance.Friends.GetFriendPersonaName(userID);
                entryDetails[0] = rank;
                entryDetails[1] = score;
                entryDetails[2] = username;
                Debug.Log("Created object #" + i + " | " + rank + " | " + score + " | " + username);
                leaderboardEntries.Add(entryDetails);
            }

            if (GameObject.Find("LeaderboardsScreen"))
            {
                GameObject.Find("LeaderboardsScreen").GetComponent <LeaderboardsController>().DisplayLeaderboard();
            }
        }
 // Token: 0x06000028 RID: 40 RVA: 0x000027EC File Offset: 0x000009EC
 public static void getAchievement(string achieve)
 {
     if (GOGHelper.active)
     {
         if (achieve.Equals("0"))
         {
             achieve = "a0";
         }
         GalaxyInstance.Stats().SetAchievement(achieve);
         GalaxyInstance.Stats().StoreStatsAndAchievements();
     }
 }
 /* Coroutine for retriving stats and achievements
  * Note: This request has to finish successfully before using any achievements or statistics related methods */
 public void RequestUserStatsAndAchievements()
 {
     Debug.Assert(!achievementRetrieveListener.retrieved && GalaxyManager.Instance.IsSignedIn());
     Debug.Log("Requesting Stats and Achievements");
     try
     {
         GalaxyInstance.Stats().RequestUserStatsAndAchievements();
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Achievements definitions could not be retrived for reason: " + e);
     }
 }
 // Retrieves global leaderboard entries
 public void RequestLeaderboardEntriesGlobal(string leaderboardName, uint rangeStart, uint rangeEnd)
 {
     Debug.Log("Trying to get leaderboard \"" + leaderboardName + "\" entries global");
     Debug.Assert(leadRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().RequestLeaderboardEntriesGlobal(leaderboardName, rangeStart, rangeEnd);
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Could not retrieve leaderboard \"" + leaderboardName + "\" global entries for reason: " + e);
     }
 }
 /* Request leadeboard definitions for later use
  * Note: This request has to finish successfully before using any leadeboards related methods */
 public void RequestLeaderboards()
 {
     Debug.Assert(!leadRetrieveListener.retrieved && GalaxyManager.Instance.IsLoggedOn());
     Debug.Log("Requesting Leaderboards");
     try
     {
         GalaxyInstance.Stats().RequestLeaderboards();
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Leaderboard definitions couldn't be retrieved for reason: " + e);
     }
 }
 // Sets users leaderboard score
 public void SetLeaderboardScore(string leaderboardName, int score, bool forceUpdate = false)
 {
     Debug.Log("Trying to set leaderboard \"" + leaderboardName + "\" score");
     Debug.Assert(leadRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().SetLeaderboardScore(leaderboardName, score, forceUpdate);
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Could not set leaderboard \"" + leaderboardName + "\" entry for reason: " + e);
     }
 }
 // Retrieves leaderboard entries around user
 public void RequestLeaderboardEntriesAroundUser(string leaderboardName, uint countBefore, uint countAfter, GalaxyID userID)
 {
     Debug.Log("Trying to get leaderboard \"" + leaderboardName + "\" entries around user");
     Debug.Assert(leadRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().RequestLeaderboardEntriesAroundUser(leaderboardName, countBefore, countAfter, userID);
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Could not retrieve leaderboard \"" + leaderboardName + "\" entries around user for reason: " + e);
     }
 }
 //  Unlocks achievement specified by API Key
 public void SetAchievement(string apiKey)
 {
     Debug.Log("Trying to unlock achievement " + apiKey);
     Debug.Assert(achievementRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().SetAchievement(apiKey);
         GalaxyInstance.Stats().StoreStatsAndAchievements();
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Achievement " + apiKey + " could not be unlocked for reason: " + e);
     }
 }
 // Resets stats and achievements
 public void ResetStatsAndAchievements()
 {
     Debug.Log("Trying to reset user stats and achievements");
     Debug.Assert(achievementRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().ResetStatsAndAchievements();
         Debug.Log("User stats and achievements reset");
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Could not get reset user stats and achievements for reason: " + e);
     }
 }
 // Sets value for a stat of int type specified by API key
 public void SetStatInt(string apiKey, int statValue)
 {
     Debug.Log("Setting stat " + apiKey);
     Debug.Assert(achievementRetrieveListener.retrieved);
     try
     {
         GalaxyInstance.Stats().SetStatInt(apiKey, statValue);
         GalaxyInstance.Stats().StoreStatsAndAchievements();
         Debug.Log("Stat " + apiKey + " set to " + statValue);
     }
     catch (GalaxyInstance.Error e)
     {
         Debug.LogWarning("Could not set value of statistic " + apiKey + " for reason: " + e);
     }
 }
    //  Gets a stat of int type by its API key
    public int GetStatInt(string apiKey)
    {
        Debug.Log("Getting stat " + apiKey);
        int statValue = 0;

        Debug.Assert(achievementRetrieveListener.retrieved);
        try
        {
            statValue = GalaxyInstance.Stats().GetStatInt(apiKey);
            Debug.Log("Stat with key " + apiKey + " has value " + statValue);
        }
        catch (GalaxyInstance.Error e)
        {
            Debug.LogWarning("Could not get value of statistic " + apiKey + " for reason: " + e);
        }
        return(statValue);
    }
    //  Gets name of achievement specified by API key
    public string GetAchievementName(string apiKey)
    {
        Debug.Log("Trying to get achievement name " + apiKey);
        string name = "";

        Debug.Assert(achievementRetrieveListener.retrieved);
        try
        {
            name = GalaxyInstance.Stats().GetAchievementDisplayName(apiKey);
            Debug.Log("Achievement display name: " + name);
        }
        catch (GalaxyInstance.Error e)
        {
            Debug.LogWarning("Could not get name of achievement " + apiKey + " for reason: " + e);
        }
        return(name);
    }
    //  Gets status of achievement specified by API key
    public bool GetAchievement(string apiKey)
    {
        Debug.Log("Trying to get achievement status for " + apiKey);
        bool unlocked = false;

        Debug.Assert(achievementRetrieveListener.retrieved);
        try
        {
            uint unlockTime = 0;
            GalaxyInstance.Stats().GetAchievement(apiKey, ref unlocked, ref unlockTime);
            Debug.Log("Achievement: \"" + apiKey + "\" unlocked: " + unlocked + " unlock time: " + unlockTime);
        }
        catch (GalaxyInstance.Error e)
        {
            Debug.LogWarning("Could not get status of achievement " + apiKey + " for reason: " + e);
        }
        return(unlocked);
    }