public ILeaderboardWrapper GetLeaderboard(string leaderboardKey = null,
                                                  UserScope userScope   = UserScope.Global, TimeScope timeScope = TimeScope.AllTime,
                                                  ushort startingRank   = 0, ushort numberOfRanks = 0, bool retrieveScore = true)
        {
            ILeaderboardWrapper returnWrapper  = null;
            ServiceSpecificIds  leaderboardIds = DefaultLeaderboardIds;

            if (string.IsNullOrEmpty(leaderboardKey) == false)
            {
                leaderboardIds = GetLeaderboardIds(leaderboardKey);
            }

            // Check if the ID is provided
            if (leaderboardIds == null)
            {
                if (Debug.isDebugBuild == true)
                {
                    Debug.LogWarning("No Leaderboard with key " + leaderboardKey + " found");
                }
            }
            else if (string.IsNullOrEmpty(leaderboardIds.Id) == true)
            {
                if (Debug.isDebugBuild == true)
                {
                    Debug.LogWarning("No Leaderboard ID provided");
                }
            }
            else
            {
                // Find a LeaderboardWrapper from the dictionary
                LeaderboardKey key = new LeaderboardKey(leaderboardIds.Id, userScope, timeScope, startingRank, numberOfRanks);
                if (allLeaderboards.TryGetValue(key, out returnWrapper) == false)
                {
                    // Create a new wrapper, and add it to the dictionary
                    returnWrapper = new LeaderboardWrapper(key);
                    allLeaderboards.Add(key, returnWrapper);

                    // Check if we should retrive scores for this leaderboard
                    if ((retrieveScore == true) && (CurrentLogInState == LogInState.AuthenticationSuccess))
                    {
                        returnWrapper.LoadLeaderboardAsync();
                    }
                }
            }
            return(returnWrapper);
        }
예제 #2
0
        public LeaderboardWrapper GetLeaderboard(string leaderboardId = null,
                                                 UserScope?userScope  = null, TimeScope timeScope = TimeScope.AllTime,
                                                 ushort startingRank  = 0, ushort numberOfRanks   = 0, bool retrieveScore = true)
        {
            LeaderboardWrapper returnWrapper = null;

            // Check if the leaderboard ID is provided
            if (string.IsNullOrEmpty(leaderboardId) == true)
            {
                // If not, replace this parameter with default leaderboard ID
                leaderboardId = DefaultLeaderboardId;
            }

            // Check if the user scope is provided
            if (userScope.HasValue == false)
            {
                // If not, replace this parameter with default leaderboard ID
                userScope = Singleton.Get <GameSettings>().LeaderboardUserScope;
            }

            // Check if the ID is provided
            if (string.IsNullOrEmpty(leaderboardId) == true)
            {
                Debug.LogWarning("No Leaderboard ID provided");
            }
            else
            {
                // Find a LeaderboardWrapper from the dictionary
                LeaderboardKey key = new LeaderboardKey(leaderboardId, userScope.Value, timeScope, startingRank, numberOfRanks);
                if (allLeaderboards.TryGetValue(key, out returnWrapper) == false)
                {
                    // Create a new wrapper, and add it to the dictionary
                    returnWrapper = new LeaderboardWrapper(key);
                    allLeaderboards.Add(key, returnWrapper);

                    // Check if we should retrive scores for this leaderboard
                    if ((retrieveScore == true) && (CurrentLogInState == LogInState.AuthenticationSuccess))
                    {
                        returnWrapper.LoadLeaderboardAsync();
                    }
                }
            }
            return(returnWrapper);
        }
예제 #3
0
 internal LeaderboardWrapper(LeaderboardKey key) :
     this(key.id, key.userScope, key.timeScope, key.startingRank, key.numberOfRanks)
 {
 }