Пример #1
0
 public LeaderboardEntry(VoxelBusters.NativePlugins.Score score, bool isUser)
 {
     Rank     = score.Rank;
     Score    = score.Value / 1000f;
     UserName = score.User.Alias.Length > 0 ? score.User.Alias : score.User.Name;
     IsUser   = isUser;
 }
		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;
		}
		public void ReportScore (string _leaderboardID, long _score, Score.ReportScoreCompletion _onCompletion)
		{
			ReportScoreWithID(_leaderboardID, _score, _onCompletion);
		}
		private void ReportScore (string _leaderboardGID, string _leaderboardID, long _score, Score.ReportScoreCompletion _onCompletion)
		{
			Score	_newScore		= CreateScoreForLocalUser(_leaderboardGID, _leaderboardID);

			if (_newScore == null)
			{
				DebugPRO.Console.LogError(Constants.kDebugTag, "[GameServices] Failed to report score.");

				if (_onCompletion != null)
					_onCompletion(false, "The requested operation could not be completed because Game Service failed to create Score object.");
				
				return;
			}

			// Set the new score value
			_newScore.Value			= _score;

			// Report
			_newScore.ReportScore(_onCompletion);
		}
		/// <summary>
		/// Reports the score to game service server.
		/// </summary>
		/// <param name="_leaderboardGID">A string used to uniquely identify <see cref="VoxelBusters.NativePlugins.Leaderboard"/> across all supported platforms.</param>
		/// <param name="_score">The score earned by <see cref="VoxelBusters.NativePlugins.LocalUser"/></param>
		/// <param name="_onCompletion">Callback to be called when operation is completed.</param>
		public void ReportScoreWithGlobalID (string _leaderboardGID, long _score, Score.ReportScoreCompletion _onCompletion)
		{
			string	_leaderboardID	= GameServicesIDHandler.GetLeaderboardID(_leaderboardGID);

			// Invoke handler
			ReportScore(_leaderboardGID, _leaderboardID, _score, _onCompletion);
		}
		protected void LoadScoresFinished (Score[] _scores, Score _localUserScore, string _error)
		{
			// Set properties
			Scores			= _scores;
			LocalUserScore	= _localUserScore;

			// Send event
			if (LoadScoreFinishedEvent != null)
				LoadScoreFinishedEvent(_scores, _localUserScore, _error);
		}
		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;
		}