Exemplo n.º 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);
        }
Exemplo n.º 2
0
 protected Leaderboard(string _identifier, string _title, eLeaderboardUserScope _userScope, eLeaderboardTimeScope _timeScope, int _maxResults, Score[] _scores, Score _localUserScore)
 {
     // Initialize properties
     Identifier     = _identifier;
     Title          = _title;
     UserScope      = _userScope;
     TimeScope      = _timeScope;
     MaxResults     = _maxResults;
     Scores         = _scores;
     LocalUserScore = _localUserScore;
 }
Exemplo n.º 3
0
        public void LoadTopScores(eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope, int _maxResults, out string _error)
        {
            // Initial value
            _error = null;

            // Set score fetch range
            Range _newRange = new Range(1, _maxResults);

            // Load scores
            FilterScoreList(_timeScope, _userScope, _newRange);
        }
Exemplo n.º 4
0
        public override void ShowLeaderboardUIWithID(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);

            // Verify auth status
            if (!VerifyUser())
            {
                return;
            }

            EditorGameCenter.Instance.ShowLeaderboardUI(_leaderboardID, _timeScope);
        }
Exemplo n.º 5
0
        public override void ShowLeaderboardUIWithID(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);

            // Verify auth status
            if (!VerifyUser())
            {
                return;
            }

            // Native method call
            showLeaderboardView(_leaderboardID, (int)_timeScope);
        }
Exemplo n.º 6
0
 protected Leaderboard(string _globalIdentifer, string _identifier, string _title = null, eLeaderboardUserScope _userScope = eLeaderboardUserScope.GLOBAL, eLeaderboardTimeScope _timeScope = eLeaderboardTimeScope.ALL_TIME, int _maxResults = kLoadScoresMaxResults, Score[] _scores = null, Score _localUserScore = null)
     : base(NPObjectManager.eCollectionType.GAME_SERVICES)
 {
     // Initialize properties
     GlobalIdentifier = _globalIdentifer;
     Identifier       = _identifier;
     Title            = _title;
     UserScope        = _userScope;
     TimeScope        = _timeScope;
     MaxResults       = _maxResults;
     Scores           = _scores;
     LocalUserScore   = _localUserScore;
 }
Exemplo n.º 7
0
        private void LoadScores(EGCLeaderboard _gcLeaderboard, eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope, Action <EditorScore[], EditorScore> _onCompletion)
        {
            EGCScore[] _filteredScoreList = GetFilteredScoreList(_gcLeaderboard, _timeScope, _userScope);
            EGCScore   _gcLocalUserScore  = _gcLeaderboard.GetScoreWithUserID(m_localUser.Info.Identifier);

            // Now get final list
            EditorScore[] _formattedScoreList      = EGCScore.ConvertToEditorScoreList(_filteredScoreList);
            EditorScore   _formattedLocalUserScore = _gcLocalUserScore == null ? null : _gcLocalUserScore.GetEditorFormatData();

            // Invoke on finished action
            if (_onCompletion != null)
            {
                _onCompletion(_formattedScoreList, _formattedLocalUserScore);
            }
        }
Exemplo n.º 8
0
        public override void ShowLeaderboardUIWithID(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);

            // Verify auth status
            if (!VerifyUser())
            {
                return;
            }

            // Native method call
            string _timeScopeString = AndroidLeaderboard.kTimeScopeMap.GetKey <eLeaderboardTimeScope>(_timeScope);

            Plugin.Call(Native.Methods.SHOW_LEADERBOARD_UI, _leaderboardID, _timeScopeString);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Opens standard view to display leaderboard scores corresponding to given platform specific id.
        /// </summary>
        /// <param name="_leaderboardID">A string used to identify the leaderboard in the current platform.</param>
        /// <param name="_timeScope">A time filter used to restrict which scores are displayed to the user.</param>
        /// <param name="_onCompletion">Callback that will be called after operation is completed.</param>
        /// <remarks>
        /// \note Incase, if you want to list out all the leaderboards that are used in your game, then pass <c>null</c> for leaderboard identifier.
        /// </remarks>
        public virtual void ShowLeaderboardUIWithID(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            // Cache callback
            ShowLeaderboardViewFinishedEvent = _onCompletion;

            // Pause unity
            this.PauseUnity();

            // Check if valid account
            if (!VerifyUser())
            {
                ShowLeaderboardViewFinished(Constants.kGameServicesUserAuthMissingError);
                return;
            }
        }
Exemplo n.º 10
0
        public override void Reset()
        {
            // Setup properties
            identifier         = null;
            isGlobalIdentifier = true;
            timeScope          = eLeaderboardTimeScope.ALL_TIME;

            // Results properties
            error = new FsmString {
                UseVariable = true
            };

            // Events properties
            successEvent = null;
            failedEvent  = null;
        }
Exemplo n.º 11
0
        public override void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUI(_leaderboardID, _timeScope, _onCompletion);

            if (string.IsNullOrEmpty(_leaderboardID))
            {
                return;
            }

            // Check if valid account
            if (!VerifyUser())
            {
                return;
            }

            LeaderboardsManager.ShowUI(_leaderboardID, _timeScope);
        }
Exemplo n.º 12
0
        public override void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUI(_leaderboardID, _timeScope, _onCompletion);

            if (string.IsNullOrEmpty(_leaderboardID))
            {
                return;
            }

            if (!VerifyUser())
            {
                return;
            }

            // Native call
            showLeaderboardView(_leaderboardID, (int)_timeScope);
        }
Exemplo n.º 13
0
        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);
            });
        }
Exemplo n.º 14
0
        public override void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            base.ShowLeaderboardUI(_leaderboardID, _timeScope, _onCompletion);

            if (string.IsNullOrEmpty(_leaderboardID))
            {
                return;
            }

            if (!VerifyUser())
            {
                return;
            }

            // Request for view
            EditorGameCenter.Instance.ShowLeaderboardUI(_leaderboardID, _timeScope, () => {
                ShowLeaderboardViewFinished(null);
            });
        }
Exemplo n.º 15
0
        public void LoadMoreScores(eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope, int _maxResults, eLeaderboardPageDirection _pageDirection, out string _error)
        {
            // Initial value
            _error = null;

            // Compute score fetch range
            Range _curRange = Range;

            if (_curRange.from == 0)
            {
                LoadTopScores(_timeScope, _userScope, _maxResults, out _error);
                return;
            }

            // Based on page direction, compute range of score to be loaded
            Range _newRange = new Range(0, _maxResults);

            if (_pageDirection == eLeaderboardPageDirection.PREVIOUS)
            {
                if (_curRange.from == 1)
                {
                    _error = "The operation could not be completed because there are no more score records.";
                    return;
                }

                _newRange.from = Mathf.Max(1, _curRange.from - _maxResults);
            }
            else if (_pageDirection == eLeaderboardPageDirection.NEXT)
            {
                _newRange.from = _curRange.from + _maxResults;

                if (_newRange.from > m_scores.Count)
                {
                    _error = "The operation could not be completed because there are no more score records.";
                    return;
                }
            }

            // Filter existing score list
            FilterScoreList(_timeScope, _userScope, _newRange);
        }
Exemplo n.º 16
0
        internal AndroidLeaderboard(IDictionary _leaderboardData)
        {
            m_identifier = _leaderboardData.GetIfAvailable <string>(kIdentifier);

            string _userScope = _leaderboardData.GetIfAvailable <string>(kUserScope);

            m_userScope = kUserScopeMap[_userScope];

            string _timeScope = _leaderboardData.GetIfAvailable <string>(kTimeScope);

            m_timeScope = kTimeScopeMap[_timeScope];

            m_title = _leaderboardData.GetIfAvailable <string>(kTitle);

            IList _scoresList = _leaderboardData.GetIfAvailable <List <object> >(kScores);

            m_scores = AndroidScore.ConvertScoreList(_scoresList);

            IDictionary _localScore = _leaderboardData.GetIfAvailable <Dictionary <string, object> >(kLocalUserScore);

            m_localUserScore = AndroidScore.ConvertScore(_localScore);
        }
Exemplo n.º 17
0
        public void LoadPlayerCenteredScores(eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope, int _maxResults, out string _error)
        {
            // Initial value
            _error = null;

            // Compute range based on player rank
            EGCUser  _localUserInfo  = EditorGameCenter.Instance.GetLocalUserInfo();
            EGCScore _localUserScore = GetScoreWithUserID(_localUserInfo.Identifier);

            if (_localUserScore == null)
            {
                _error = "The operation could not be completed because local user score info not found.";
                return;
            }

            int   _localPlayerRank = _localUserScore.Rank;
            int   _loadFrom        = Mathf.Max(1, _localPlayerRank - Mathf.FloorToInt(_maxResults * 0.5f));
            Range _newRange        = new Range(_loadFrom, _maxResults);

            // Load scores
            FilterScoreList(_timeScope, _userScope, _newRange);
        }
        public override void Reset()
        {
            // Setup properties
            identifier         = null;
            isGlobalIdentifier = true;
            userScope          = eLeaderboardUserScope.GLOBAL;
            timeScope          = eLeaderboardTimeScope.ALL_TIME;
            maxResults         = 20;
            loadUserImages     = false;

            // Results properties
            count = new FsmInt {
                UseVariable = true
            };
            error = new FsmString {
                UseVariable = true
            };

            // Event properties
            successEvent = null;
            failedEvent  = null;
        }
Exemplo n.º 19
0
        /// <summary>
        /// Show the leaderboard UI with a specific leaderboard shown initially with a specific time scope.
        /// </summary>
        /// <param name="_leaderboardID">A string used to uniquely identify the specific <see cref="VoxelBusters.NativePlugins.Leaderboard"/> object refers to.</param>
        /// <param name="_timeScope">Time scope initially used while showing leaderboard UI.</param>
        /// <param name="_onCompletion">Callback called when Leaderboard view is closed.</param>
        public virtual void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            // Cache callback
            m_showLeaderboardViewFinished = _onCompletion;

            // Pause unity
            this.PauseUnity();

            // Check if learboard identifier is valid
            if (string.IsNullOrEmpty(_leaderboardID))
            {
                DebugPRO.Console.LogError(Constants.kDebugTag, "[GameServices] Leaderboard identifier cant be null/empty.");
                ShowLeaderboardViewFinished(null);
                return;
            }

            // Check if valid account
            if (!VerifyUser())
            {
                ShowLeaderboardViewFinished(null);
                return;
            }
        }
Exemplo n.º 20
0
		protected Leaderboard (string _identifier, string _title, eLeaderboardUserScope _userScope, eLeaderboardTimeScope _timeScope, int _maxResults, Score[] _scores, Score _localUserScore)
		{
			// Initialize properties
			Identifier			= _identifier;
			Title				= _title;
			UserScope			= _userScope;
			TimeScope			= _timeScope;
			MaxResults			= _maxResults;
			Scores				= _scores;
			LocalUserScore		= _localUserScore;
		}
Exemplo n.º 21
0
        public void FilterScoreList(eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope, Range _range)
        {
            // Update range
            Range = _range;

            // User scope based filtering
            List <EGCScore> _usScoreList   = new List <EGCScore>();
            EGCUser         _localUserInfo = EditorGameCenter.Instance.GetLocalUserInfo();

            if (_userScope == eLeaderboardUserScope.GLOBAL)
            {
                _usScoreList.AddRange(m_scores);
            }
            else
            {
                string[] _friendIDList = _localUserInfo.Friends;

                foreach (EGCScore _curScore in m_scores)
                {
                    string _curUserID = _curScore.User.Identifier;

                    if (_friendIDList.Any(_curFriendID => _curFriendID.Equals(_curUserID)))
                    {
                        _usScoreList.Add(_curScore);
                    }
                }
            }

            // Time scope based filtering
            List <EGCScore> _tsScoreList = new List <EGCScore>();

            if (_timeScope == eLeaderboardTimeScope.ALL_TIME)
            {
                _tsScoreList.AddRange(_usScoreList);
            }
            else
            {
                TimeSpan _timespan;

                if (_timeScope == eLeaderboardTimeScope.TODAY)
                {
                    _timespan = TimeSpan.FromDays(1);
                }
                else
                {
                    _timespan = TimeSpan.FromDays(7);
                }

                long _intervalStartTick = DateTime.Now.Subtract(_timespan).Ticks;
                long _intervalEndTick   = DateTime.Now.Ticks;

                foreach (EGCScore _curScore in _usScoreList)
                {
                    long _curScoreTicks = _curScore.Date.Ticks;

                    if (_curScoreTicks >= _intervalStartTick && _curScoreTicks <= _intervalEndTick)
                    {
                        _tsScoreList.Add(_curScore);
                    }
                }
            }

            // Now get elements based on range
            List <EGCScore> _finalScore = new List <EGCScore>();
            int             _startIndex = _range.from - 1;
            int             _endIndex   = _startIndex + _range.count;

            for (int _iter = _startIndex; (_iter < _tsScoreList.Count && _iter < _endIndex); _iter++)
            {
                _finalScore.Add(_tsScoreList[_iter]);
            }

            m_lastQueryResults = _finalScore.ToArray();
        }
		public override void ShowLeaderboardUI (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			base.ShowLeaderboardUI(_leaderboardID, _timeScope, _onCompletion);

			if (string.IsNullOrEmpty(_leaderboardID))
				return;

			if (!VerifyUser())
				return;
		
			// Request for view
			EditorGameCenter.Instance.ShowLeaderboardUI(_leaderboardID, _timeScope, ()=>{
				ShowLeaderboardViewFinished(null);
			});
		}
Exemplo n.º 23
0
 public void ShowLeaderboardUI(string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
 {
     ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
 }
		internal AndroidLeaderboard (IDictionary _leaderboardData)
		{
			m_identifier			= _leaderboardData.GetIfAvailable<string>(kIdentifier);	

			string _userScope		= _leaderboardData.GetIfAvailable<string>(kUserScope);
			m_userScope				= kUserScopeMap[_userScope];

			string _timeScope		= _leaderboardData.GetIfAvailable<string>(kTimeScope);
			m_timeScope				= kTimeScopeMap[_timeScope];

			m_title					= _leaderboardData.GetIfAvailable<string>(kTitle);
			
			IList _scoresList		= _leaderboardData.GetIfAvailable<List<object>>(kScores);			
			m_scores				= AndroidScore.ConvertScoreList(_scoresList);

			IDictionary _localScore	= _leaderboardData.GetIfAvailable<Dictionary<string, object>>(kLocalUserScore);			
			m_localUserScore		= AndroidScore.ConvertScore(_localScore);
		}
Exemplo n.º 25
0
 private string GetTimeScopeString(eLeaderboardTimeScope _timeScope)
 {
     return(AndroidLeaderboard.kTimeScopeMap.GetKey <eLeaderboardTimeScope>(_timeScope));
 }
		protected Leaderboard (string _globalIdentifer, string _identifier, string _title = null, eLeaderboardUserScope _userScope = eLeaderboardUserScope.GLOBAL, eLeaderboardTimeScope _timeScope = eLeaderboardTimeScope.ALL_TIME, int _maxResults = 20, Score[] _scores = null, Score _localUserScore = null)
			: base (NPObjectManager.eCollectionType.GAME_SERVICES)
		{
			// Initialize properties
			GlobalIdentifier	= _globalIdentifer;
			Identifier			= _identifier;
			Title				= _title;
			UserScope			= _userScope;
			TimeScope			= _timeScope;
			MaxResults			= _maxResults;
			Scores				= _scores;
			LocalUserScore		= _localUserScore;
		}
		public override void ShowLeaderboardUIWithID (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
			
			// Verify auth status
			if (!VerifyUser())
				return;

			// Native method call
			showLeaderboardView(_leaderboardID, (int)_timeScope);
		}
		public override void ShowLeaderboardUIWithID (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
			
			// Verify auth status
			if (!VerifyUser())
				return;
			
			EditorGameCenter.Instance.ShowLeaderboardUI(_leaderboardID, _timeScope);
		}
		public void ShowUI(string _leaderboardID, eLeaderboardTimeScope _timeScope)
		{
			// Show leaderboard
			Plugin.Call(AndroidNativeInfo.Methods.SHOW_LEADERBOARD_UI, _leaderboardID, GetTimeScopeString(_timeScope));
			
		}
Exemplo n.º 30
0
 public void ShowUI(string _leaderboardID, eLeaderboardTimeScope _timeScope)
 {
     // Show leaderboard
     Plugin.Call(AndroidNativeInfo.Methods.SHOW_LEADERBOARD_UI, _leaderboardID, GetTimeScopeString(_timeScope));
 }
		public override void ShowLeaderboardUI (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			base.ShowLeaderboardUI(_leaderboardID, _timeScope, _onCompletion);
			
			if (string.IsNullOrEmpty(_leaderboardID))
				return;
			
			if (!VerifyUser())
				return;

			// Native call
			showLeaderboardView(_leaderboardID, (int)_timeScope);
		}
		public void ShowLeaderboardUI (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
		}
		/// <summary>
		/// Show the leaderboard UI with a specific time scope.
		/// </summary>
		/// <param name="_leaderboardGID">A string used to uniquely identify <see cref="VoxelBusters.NativePlugins.Leaderboard"/> across all supported platforms.</param>
		/// <param name="_timeScope">Time scope initially used while showing leaderboard UI.</param>
		/// <param name="_onCompletion">Callback called when Leaderboard view is closed.</param>
		public void ShowLeaderboardUIWithGlobalID (string _leaderboardGID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			string	_leaderboardID	= GameServicesIDHandler.GetLeaderboardID(_leaderboardGID);

			ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
		}
		public override void ShowLeaderboardUIWithID (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			base.ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
			
			// Verify auth status
			if (!VerifyUser())
				return;
			
			// Native method call
			string _timeScopeString = AndroidLeaderboard.kTimeScopeMap.GetKey<eLeaderboardTimeScope>(_timeScope);
			Plugin.Call(Native.Methods.SHOW_LEADERBOARD_UI, _leaderboardID, _timeScopeString);
		}
Exemplo n.º 35
0
        private EGCScore[] GetFilteredScoreList(EGCLeaderboard _gcLeaderboard, eLeaderboardTimeScope _timeScope, eLeaderboardUserScope _userScope)
        {
            List <EGCScore> _gcScores = _gcLeaderboard.Scores;

            // User scope based filtering
            List <EGCScore> _usScoreList = new List <EGCScore>();

            if (_userScope == eLeaderboardUserScope.GLOBAL)
            {
                _usScoreList.AddRange(_gcScores);
            }
            else
            {
                string[] _friendIDList = m_localUser.Info.Friends;

                foreach (EGCScore _curScore in _gcScores)
                {
                    string _curUserID = _curScore.User.Identifier;

                    if (_friendIDList.Any(_curFriendID => _curFriendID.Equals(_curUserID)))
                    {
                        _usScoreList.Add(_curScore);
                    }
                }
            }

            // Time scope based filtering
            List <EGCScore> _tsScoreList = new List <EGCScore>();

            if (_timeScope == eLeaderboardTimeScope.ALL_TIME)
            {
                _tsScoreList.AddRange(_usScoreList);
            }
            else
            {
                TimeSpan _timespan;

                if (_timeScope == eLeaderboardTimeScope.TODAY)
                {
                    _timespan = TimeSpan.FromDays(1);
                }
                else
                {
                    _timespan = TimeSpan.FromDays(7);
                }

                long _intervalStartTick = DateTime.Now.Subtract(_timespan).Ticks;
                long _intervalEndTick   = DateTime.Now.Ticks;

                foreach (EGCScore _curScore in _usScoreList)
                {
                    long _curScoreTicks = _curScore.Date.Ticks;

                    if (_curScoreTicks >= _intervalStartTick && _curScoreTicks <= _intervalEndTick)
                    {
                        _tsScoreList.Add(_curScore);
                    }
                }
            }

            // Now get elements based on range
            Range           _range      = _gcLeaderboard.Range;
            List <EGCScore> _finalScore = new List <EGCScore>();
            int             _startIndex = _range.from - 1;
            int             _endIndex   = _startIndex + _range.count;

            for (int _iter = _startIndex; (_iter < _tsScoreList.Count && _iter < _endIndex); _iter++)
            {
                _finalScore.Add(_tsScoreList[_iter]);
            }

            return(_finalScore.ToArray());
        }
Exemplo n.º 36
0
        /// <summary>
        /// Opens standard view to display leaderboard scores corresponding to given unified id.
        /// </summary>
        /// <param name="_leaderboardGID">An unified string internally used to identify the leaderboard across all the supported platforms.</param>
        /// <param name="_timeScope">A time filter used to restrict which scores are displayed to the user.</param>
        /// <param name="_onCompletion">Callback that will be called after operation is completed.</param>
        /// <remarks>
        /// Incase, if you want to list out all the leaderboards that are used in your game, then pass <c>null</c> for leaderboard identifier.
        /// \note Works only if, leaderboard metadata was configured in NPSettings or else explicitely set using <see cref="SetLeaderboardMetadataCollection"/>.
        /// </remarks>
        public void ShowLeaderboardUIWithGlobalID(string _leaderboardGID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
        {
            string _leaderboardID = GameServicesUtils.GetLeaderboardID(_leaderboardGID);

            ShowLeaderboardUIWithID(_leaderboardID, _timeScope, _onCompletion);
        }
		/// <summary>
		/// Show the leaderboard UI with a specific time scope.
		/// </summary>
		/// <param name="_leaderboardID">A string used to uniquely identify <see cref="VoxelBusters.NativePlugins.Leaderboard"/> specific to current platform.</param>
		/// <param name="_timeScope">Time scope initially used while showing leaderboard UI.</param>
		/// <param name="_onCompletion">Callback called when Leaderboard view is closed.</param>
		public virtual void ShowLeaderboardUIWithID (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			// Cache callback
			ShowLeaderboardViewFinishedEvent	= _onCompletion;

			// Pause unity
			this.PauseUnity();

			// Check if valid account
			if (!VerifyUser())
			{
				ShowLeaderboardViewFinished(Constants.kGameServicesUserAuthMissingError);
				return;
			}
		}
		/// <summary>
		/// Show the leaderboard UI with a specific leaderboard shown initially with a specific time scope.
		/// </summary>
		/// <param name="_leaderboardID">A string used to uniquely identify the specific <see cref="VoxelBusters.NativePlugins.Leaderboard"/> object refers to.</param>
		/// <param name="_timeScope">Time scope initially used while showing leaderboard UI.</param>
		/// <param name="_onCompletion">Callback called when Leaderboard view is closed.</param>
		public virtual void ShowLeaderboardUI (string _leaderboardID, eLeaderboardTimeScope _timeScope, GameServiceViewClosed _onCompletion)
		{
			// Cache callback
			m_showLeaderboardViewFinished	= _onCompletion;

			// Pause unity
			this.PauseUnity();

			// Check if learboard identifier is valid
			if (string.IsNullOrEmpty(_leaderboardID))
			{
				DebugPRO.Console.LogError(Constants.kDebugTag, "[GameServices] Leaderboard identifier cant be null/empty.");
				ShowLeaderboardViewFinished(null);
				return;
			}

			// Check if valid account
			if (!VerifyUser())
			{
				ShowLeaderboardViewFinished(null);
				return;
			}
		}
		private string GetTimeScopeString(eLeaderboardTimeScope _timeScope)
		{
			return  AndroidLeaderboard.kTimeScopeMap.GetKey<eLeaderboardTimeScope>(_timeScope);
		}