コード例 #1
0
        private void OnReceivingScores(string _loadedScoresJsonStr, Leaderboard.LoadScoreCompletion _callback)
        {
            IList _scoresJsonList = JSONUtility.FromJSON(_loadedScoresJsonStr) as IList;

            Score[] _scores         = null;
            Score   _localUserScore = null;

            if (_scoresJsonList != null)
            {
                int _count = _scoresJsonList.Count;
                if (_count > 0)
                {
                    _localUserScore = AndroidScore.ConvertScore(_scoresJsonList[_count - 1] as IDictionary);

                    //Now remove the last element. As we stored user score in the last entry.
                    _scoresJsonList.RemoveAt(_count - 1);

                    _scores = AndroidScore.ConvertScoreList(_scoresJsonList);


                    if (_localUserScore.User == null)                   //Empty entry
                    {
                        _localUserScore = null;
                    }
                }
            }

            // Send callback
            if (_callback != null)
            {
                _callback(_scores, _localUserScore);
            }
        }
コード例 #2
0
        internal AndroidLeaderboard(IDictionary _leaderboardData)
        {
            Identifier = _leaderboardData.GetIfAvailable <string>(kIdentifier);

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

            UserScope = kUserScopeMap[_userScope];

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

            TimeScope = kTimeScopeMap[_timeScope];

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

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

            Scores = AndroidScore.ConvertScoreList(_scoresList);

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

            LocalUserScore = AndroidScore.ConvertScore(_localScore);


            // Set global identifier
            GlobalIdentifier = GameServicesIDHandler.GetLeaderboardGID(Identifier);
        }
コード例 #3
0
        internal static AndroidScore[] ConvertScoreList(IList _scoreList)
        {
            if (_scoreList == null)
            {
                return(null);
            }

            int _count = _scoreList.Count;

            AndroidScore[] _androidScoreList = new AndroidScore[_count];

            for (int _iter = 0; _iter < _count; _iter++)
            {
                _androidScoreList[_iter] = new AndroidScore(_scoreList[_iter] as IDictionary);
            }

            return(_androidScoreList);
        }
コード例 #4
0
        protected override void LoadScoresFinished(IDictionary _dataDict)
        {
            string      _error    = _dataDict.GetIfAvailable <string>(GameServicesAndroid.kNativeMessageError);
            IDictionary _infoDict = _dataDict.GetIfAvailable <IDictionary>(kLeaderboardInfo);

            if (_infoDict != null)
            {
                // Update scores
                IDictionary _localScoreInfoDict = _infoDict.GetIfAvailable <IDictionary>(kLeaderboardLocalScore);
                IList       _scoresJSONList     = _infoDict.GetIfAvailable <IList>(kLeaderboardScores);

                LocalUserScore = AndroidScore.ConvertScore(_localScoreInfoDict);
                Scores         = AndroidScore.ConvertScoreList(_scoresJSONList);
            }

            // Call finish handler
            LoadScoresFinished(Scores, LocalUserScore, _error);
        }
コード例 #5
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);
        }
コード例 #6
0
		internal static AndroidScore[] ConvertScoreList (IList _scoreList)
		{
			if (_scoreList == null)
				return null;
			
			int					_count				= _scoreList.Count;
			AndroidScore[]		_androidScoreList	= new AndroidScore[_count];
			
			for (int _iter = 0; _iter < _count; _iter++)
				_androidScoreList[_iter]			= new AndroidScore(_scoreList[_iter] as IDictionary);
			
			return _androidScoreList;
		}
コード例 #7
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);
		}