Exemplo n.º 1
0
        private void LoadUserInfo(LoadScoreCompletion _onCompletion)
        {
            IScore[] _gcScoreList  = m_leaderboardData.scores;
            int      _gcScoreCount = _gcScoreList.Length;
            Dictionary <string, IScore> _gcUserIDScoreMap = new Dictionary <string, IScore>(_gcScoreCount);

            for (int _iter = 0; _iter < _gcScoreCount; _iter++)
            {
                IScore _curScore = _gcScoreList[_iter];

                // Add entries to user id score map
                _gcUserIDScoreMap.Add(_curScore.userID, _curScore);
            }

            // Now load users
            NPBinding.GameServices.LoadUsers(_gcUserIDScoreMap.Keys.ToArray(), (User[] _userList) => {
                if (_userList == null)
                {
                    if (_onCompletion != null)
                    {
                        _onCompletion(null, null);
                    }

                    return;
                }
                else
                {
                    Score[]         _finalScoreList = new iOSScore[_gcScoreCount];

                    for (int _iter = 0; _iter < _gcScoreCount; _iter++)
                    {
                        User _curUser     = _userList[_iter];
                        IScore _userScore = _gcUserIDScoreMap[_curUser.Identifier];

                        // Add score and user info
                        _finalScoreList[_iter] = new iOSScore(_userScore, _curUser);
                    }

                    // Set new values
                    Scores         = _finalScoreList;
                    LocalUserScore = new iOSScore(m_leaderboardData.localUserScore, NPBinding.GameServices.LocalUser);

                    // Trigger callback
                    if (_onCompletion != null)
                    {
                        _onCompletion(Scores, LocalUserScore);
                    }

                    return;
                }
            });
        }
Exemplo n.º 2
0
        protected override void LoadScoresFinished(IDictionary _dataDict)
        {
            iOSScore[] _scoreList      = null;
            iOSScore   _localUserScore = null;

            // Parse native response
            string      _error    = _dataDict.GetIfAvailable <string>(GameServicesIOS.kNativeMessageErrorKey);
            IDictionary _infoDict = _dataDict.GetIfAvailable <IDictionary>(kLeaderboardInfoKey);

            if (_infoDict != null)
            {
                string      _title                  = _infoDict.GetIfAvailable <string>(kTitleKey);
                IList       _scoresJSONList         = _infoDict.GetIfAvailable <IList>(kScoresKey);
                IDictionary _localUserScoreInfoDict = _infoDict.GetIfAvailable <IDictionary>(kLocalScoreKey);

                if (_scoresJSONList != null)
                {
                    int _count = _scoresJSONList.Count;
                    _scoreList = new iOSScore[_count];

                    for (int _iter = 0; _iter < _count; _iter++)
                    {
                        _scoreList[_iter] = new iOSScore((IDictionary)_scoresJSONList[_iter]);
                    }
                }

                if (_localUserScoreInfoDict != null)
                {
                    _localUserScore = new iOSScore(_localUserScoreInfoDict);
                }

                // Update leaderboard properties
                this.Title = _title;
            }

            // Invoke finish handler
            LoadScoresFinished(_scoreList, _localUserScore, _error);
        }
Exemplo n.º 3
0
        private void SetScores(IList _scoresJSONList, IDictionary _localScoreInfoDict)
        {
            // Set default values
            Scores         = null;
            LocalUserScore = null;

            // Set scores list
            if (_scoresJSONList != null)
            {
                int _count = _scoresJSONList.Count;
                Scores = new iOSScore[_count];

                for (int _iter = 0; _iter < _count; _iter++)
                {
                    Scores[_iter] = new iOSScore((IDictionary)_scoresJSONList[_iter]);
                }
            }

            // Set local score info
            if (_localScoreInfoDict != null)
            {
                LocalUserScore = new iOSScore(_localScoreInfoDict);
            }
        }
		private void SetScores (IList _scoresJSONList, IDictionary _localScoreInfoDict)
		{
			// Set default values
			Scores			= null;
			LocalUserScore	= null;
			
			// Set scores list
			if (_scoresJSONList != null)
			{
				int	_count	= _scoresJSONList.Count;
				Scores		= new iOSScore[_count];
				
				for (int _iter = 0; _iter < _count; _iter++)
					Scores[_iter]	= new iOSScore((IDictionary)_scoresJSONList[_iter]);
			}
			
			// Set local score info
			if (_localScoreInfoDict != null)
				LocalUserScore		= new iOSScore(_localScoreInfoDict);
		}
		private void LoadUserInfo (LoadScoreCompletion _onCompletion)
		{
			IScore[]					_gcScoreList		= m_leaderboardData.scores;
			int 						_gcScoreCount		= _gcScoreList.Length;
			Dictionary<string, IScore>	_gcUserIDScoreMap	= new Dictionary<string, IScore>(_gcScoreCount);
			
			for (int _iter = 0; _iter < _gcScoreCount; _iter++)
			{
				IScore			_curScore		= _gcScoreList[_iter];
				
				// Add entries to user id score map
				_gcUserIDScoreMap.Add(_curScore.userID, _curScore);
			}
			
			// Now load users
			NPBinding.GameServices.LoadUsers(_gcUserIDScoreMap.Keys.ToArray(), (User[] _userList)=>{
				
				if (_userList == null)
				{
					if (_onCompletion != null)
						_onCompletion(null, null);

					return;
				}
				else
				{
					Score[]		_finalScoreList	= new iOSScore[_gcScoreCount];
					
					for (int _iter = 0; _iter < _gcScoreCount; _iter++)
					{
						User		_curUser	= _userList[_iter];
						IScore		_userScore	= _gcUserIDScoreMap[_curUser.Identifier];
						
						// Add score and user info
						_finalScoreList[_iter]	= new iOSScore(_userScore, _curUser);
					}
					
					// Set new values
					Scores 						= _finalScoreList;
					LocalUserScore				= new iOSScore(m_leaderboardData.localUserScore, NPBinding.GameServices.LocalUser);

					// Trigger callback
					if (_onCompletion != null)
						_onCompletion(Scores, LocalUserScore);

					return;
				}
			});
		}