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); }
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; }
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; }
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); }
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); }
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; }
private string GetUserScopeString(eLeaderboardUserScope _userScope) { return(AndroidLeaderboard.kUserScopeMap.GetKey <eLeaderboardUserScope>(_userScope)); }
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; }
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()); }
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); } }
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(); }
private string GetUserScopeString(eLeaderboardUserScope _userScope) { return AndroidLeaderboard.kUserScopeMap.GetKey<eLeaderboardUserScope>(_userScope); }
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; }
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); }