Beispiel #1
0
        public void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, Action _onCompletion)
        {
            // Check if user has logged in
            if (!VerifyUser())
            {
                if (_onCompletion != null)
                {
                    _onCompletion();
                }

                return;
            }

            // Application needs to be in play mode
            if (!Application.isPlaying)
            {
                DebugPRO.Console.LogError(Constants.kDebugTag, "[GameServices] Works in play mode only.");

                if (_onCompletion != null)
                {
                    _onCompletion();
                }

                return;
            }

            // Get leaderboard info
            EGCLeaderboard _gcLeaderboard = GetLeaderboardWithID(_leaderboardID);

            if (_gcLeaderboard == null)
            {
                if (_onCompletion != null)
                {
                    _onCompletion();
                }

                return;
            }

            // Set leaderboard score fetch range
            Range _oldRange = _gcLeaderboard.Range;
            Range _newRange = new Range(1, int.MaxValue);

            _gcLeaderboard.Range = _newRange;

            // Fetch scores from leaderboard
            EGCScore[] _scoreList = GetFilteredScoreList(_gcLeaderboard, _timeScope, eLeaderboardUserScope.GLOBAL);

            // Reset range to old value
            _gcLeaderboard.Range = _oldRange;

            // Show UI
            if (m_gameCenterUI == null)
            {
                CreateGameCenterUIInstance();
            }

            m_gameCenterUI.ShowLeaderboardUI(_scoreList, _onCompletion);
        }
        public void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope)
        {
            // Check if user has logged in
            if (!VerifyUser())
            {
                OnShowLeaderboardViewFinished(Constants.kGameServicesUserAuthMissingError);
                return;
            }

            // Application needs to be in play mode
            if (!Application.isPlaying)
            {
                OnShowLeaderboardViewFinished("The operation could not be completed because view is available only in play mode.");
                return;
            }

            // Get leaderboard info
            EGCLeaderboard _gcLeaderboard = GetLeaderboardWithID(_leaderboardID);

            if (_gcLeaderboard == null)
            {
                OnShowLeaderboardViewFinished(Constants.kGameServicesIdentifierInfoNotFoundError);
                return;
            }

            // Set leaderboard score fetch range
            Range _oldRange = _gcLeaderboard.Range;
            Range _newRange = new Range(1, int.MaxValue);

            // Fetch scores from leaderboard
            _gcLeaderboard.FilterScoreList(_timeScope, eLeaderboardUserScope.GLOBAL, _newRange);

            // Reset range to old value
            _gcLeaderboard.Range = _oldRange;

            // Show UI
            if (m_gameCenterUI == null)
            {
                CreateGameCenterUIInstance();
            }

            m_gameCenterUI.ShowLeaderboardUI(_gcLeaderboard.GetLastQueryResults(), () => {
                // Invoke handler
                OnShowLeaderboardViewFinished(null);
            });
        }