Esempio n. 1
0
		public GetScoresFailedEvent(Provider provider, Leaderboard from, bool fromStart, string errorDescription, string payload)
			: base(provider, payload)
		{
			this.From = from;
			this.FromStart = fromStart;
			this.ErrorDescription = errorDescription;
		}
Esempio n. 2
0
        /// <summary>
        /// See docs in <see cref="SoomlaProfile.GetScores"/>
        /// </summary>
        public void GetScores(Leaderboard owner, bool fromStart, SocialPageDataSuccess <Score> success, FailureHandler fail)
        {
            FB.API("/app/scores?fields=score,user",
                   HttpMethod.GET,
                   (IGraphResult result) => {
                if (result.Error != null)
                {
                    SoomlaUtils.LogDebug(TAG, "GetScoreCallback[result.Error]: " + result.Error);
                    fail(result.Error);
                }
                else
                {
                    SoomlaUtils.LogDebug(TAG, "GetScoreCallback[result.Text]: " + result.RawResult);
                    JSONObject jsonFeed = new JSONObject(result.RawResult);

                    SocialPageData <Score> resultData = new SocialPageData <Score>();
                    resultData.PageData   = ScoreFromFBJsonObjs(owner, jsonFeed["data"].list);
                    resultData.PageNumber = 1;
                    resultData.HasMore    = false;

                    success(resultData);
                }
            });
        }
Esempio n. 3
0
 public override void ReportScore(Leaderboard owner, int value, SingleObjectSuccess <Score> success, FailureHandler fail)
 {
 }
		/// <summary>
		/// Handles an <c>onGetScoresFinished</c> event
		/// </summary>
		/// <param name="message">
		/// Will contain a numeric representation of <c>Provider</c>,
		/// and payload</param>
		public void onGetScoresFinished(String message) {
			SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetScoresFinished");

			JSONObject eventJson = new JSONObject(message);

			Provider provider = Provider.fromInt ((int)eventJson["provider"].n);
			Leaderboard owner = new Leaderboard(eventJson["leaderboard"]);

			bool hasMore = eventJson["hasMore"].b;

			JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

			JSONObject scoresArray = eventJson ["scores"];
			List<Score> scores = new List<Score>();
			foreach (JSONObject scoreJson in scoresArray.list) {
				scores.Add(new Score(scoreJson));
			}

			SocialPageData<Score> data = new SocialPageData<Score>();
			data.PageData = scores;
			data.PageNumber = 0;
			data.HasMore = hasMore;

			ProfileEvents.OnGetScoresFinished(new GetScoresFinishedEvent(provider, owner, data, ProfilePayload.GetUserPayload(payloadJSON)));
		}
 public ReportScoreFinishedEvent(Provider provider, Leaderboard destination, Score newScore, string payload) : base(provider, payload)
 {
     this.Destination = destination;
     this.Score       = newScore;
 }
Esempio n. 6
0
		public GetScoresStartedEvent(Provider provider, Leaderboard from, bool fromStart, string payload) : base(provider, payload)
		{
			this.From = from;
			this.FromStart = fromStart;
		}
		protected virtual void _submitScore(Provider provider, Leaderboard targetLeaderboard, int score, string payload) { }
		/// <summary>
		/// Submit score into selected leaderboard
		/// Supported platforms: GameCenter.
		///
		/// NOTE: This operation requires a successful login.
		/// </summary>
		/// <param name="provider">The <c>Provider</c> to fetch contacts from.</param>
		/// <param name="targetLeaderboard">The <c>Leaderboard</c> score will be written to.</param>
		/// <param name="score">Value of score will be written to leaderboard.</param>
		/// <param name="payload">A string to receive when the function returns.</param>
		public static void SubmitScore(Provider provider, Leaderboard targetLeaderboard, int score, string payload = "", Reward reward = null) {
			IGameServicesProvider targetProvider = (IGameServicesProvider)GetProviderImplementation(provider);
			string userPayload = (payload == null) ? "" : payload;
			if (targetProvider == null)
				return;

			if (targetProvider.IsNativelyImplemented())
			{
				//fallback to native
				string rewardId = reward != null ? reward.ID: "";
				instance._submitScore(provider, targetLeaderboard, score, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
			}
			else
			{
				ProfileEvents.OnSubmitScoreStarted(new SubmitScoreStartedEvent(provider, targetLeaderboard, payload));
				targetProvider.SubmitScore(targetLeaderboard, score, (Score newScore) => {
					if (reward != null) {
						reward.Give();
					}
					ProfileEvents.OnSubmitScoreFinished(new SubmitScoreFinishedEvent(provider, targetLeaderboard, newScore, payload));
				}, (string message) => {
					ProfileEvents.OnSubmitScoreFailed(new SubmitScoreFailedEvent(provider, targetLeaderboard, message, payload));
				});
			}
		}
		public SubmitScoreFinishedEvent(Provider provider, Leaderboard destination, Score newScore, string payload) : base(provider, payload)
		{
			this.Destination = destination;
			this.Score = newScore;
		}
Esempio n. 10
0
		/// <summary>
		/// Handles an <c>onReportScoreFinished</c> event
		/// </summary>
		/// <param name="message">
		/// Will contain a numeric representation of <c>Provider</c>,
		/// and payload</param>
		public void onReportScoreFinished(String message) {
			SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onReportScoreFinished");

			JSONObject eventJson = new JSONObject(message);

			Provider provider = Provider.fromInt ((int)eventJson["provider"].n);
			Leaderboard owner = new Leaderboard(eventJson["leaderboard"]);
			Score score = new Score(eventJson["score"]);

			JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

			ProfileEvents.OnReportScoreFinished(new ReportScoreFinishedEvent(provider, owner, score, ProfilePayload.GetUserPayload(payloadJSON)));
		}
Esempio n. 11
0
 public GetScoresStartedEvent(Provider provider, Leaderboard from, bool fromStart, string payload) : base(provider, payload)
 {
     this.From      = from;
     this.FromStart = fromStart;
 }
Esempio n. 12
0
		public GetScoresFinishedEvent(Provider provider, Leaderboard from, SocialPageData<Score> scores, string payload)
			: base(provider, payload)
		{
			this.From = from;
			this.Scores = scores;
		}
Esempio n. 13
0
		public SubmitScoreFailedEvent(Provider provider, Leaderboard destination, string errorDescripion, string payload) : base(provider, payload)
		{
			this.Destination = destination;
			this.ErrorDescription = errorDescripion;
		}
 public override void GetScores(Leaderboard owner, bool fromStart, SocialPageDataSuccess<Score> success, FailureHandler fail)
 {
 }
		public void SubmitScore(Leaderboard targetLeaderboard, int value, SingleObjectSuccess<Score> success, FailureHandler fail) {}
 public override void ReportScore(Leaderboard owner, int value, SingleObjectSuccess<Score> success, FailureHandler fail)
 {
 }
Esempio n. 17
0
		public Score(JSONObject jsonSC) {
			this.Leaderboard = new Leaderboard(jsonSC[PJSONConsts.UP_LEADERBOARD]);
			this.Player = new UserProfile(jsonSC[PJSONConsts.UP_USER_PROFILE]);
			this.Rank = (long)jsonSC[PJSONConsts.UP_SCORE_RANK].n;
			this.Value = (long)jsonSC[PJSONConsts.UP_SCORE_VALUE].n;
		}
Esempio n. 18
0
 public SubmitScoreStartedEvent(Provider provider, Leaderboard destination, string payload) : base(provider, payload)
 {
     this.Destination = destination;
 }
Esempio n. 19
0
 public void GetScores(Leaderboard owner, bool fromStart, SocialPageDataSuccess <Score> success, FailureHandler fail)
 {
 }
Esempio n. 20
0
		protected virtual void _getScores(Provider provider, Leaderboard from, bool fromStart, string payload) { }
Esempio n. 21
0
 public void SubmitScore(Leaderboard targetLeaderboard, int value, SingleObjectSuccess <Score> success, FailureHandler fail)
 {
 }
Esempio n. 22
0
		/// <summary>
		/// Fetches Scores for selected leaderboard.
		/// Supported platforms: GameCenter.
		///
		/// NOTE: This operation requires a successful login.
		/// </summary>
		/// <param name="provider">The <c>Provider</c> to fetch contacts from.</param>
		/// <param name="from">The <c>Leaderboard</c> scores related to.</param>
		/// <param name="payload">A string to receive when the function returns.</param>
		public static void GetScores(Provider provider, Leaderboard from, bool fromStart = false, string payload = "", Reward reward = null) {
			IGameServicesProvider targetProvider = (IGameServicesProvider)GetProviderImplementation(provider);
			string userPayload = (payload == null) ? "" : payload;
			if (targetProvider == null)
				return;

			if (targetProvider.IsNativelyImplemented())
			{
				//fallback to native
				string rewardId = reward != null ? reward.ID: "";
				instance._getScores(provider, from, fromStart, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
			}
			else
			{
				ProfileEvents.OnGetScoresStarted(new GetScoresStartedEvent(provider, from, fromStart, payload));
				targetProvider.GetScores(from, fromStart, (SocialPageData<Score> scores) => {
					if (reward != null) {
						reward.Give();
					}
					ProfileEvents.OnGetScoresFinished(new GetScoresFinishedEvent(provider, from, scores, payload));
				}, (string message) => {
					ProfileEvents.OnGetScoresFailed(new GetScoresFailedEvent(provider, from, fromStart, message, payload));
				});
			}
		}
Esempio n. 23
0
 protected virtual void _reportScore(Provider provider, Leaderboard where, int score, string payload)
 {
 }
Esempio n. 24
0
 public SubmitScoreFailedEvent(Provider provider, Leaderboard destination, string errorDescripion, string payload) : base(provider, payload)
 {
     this.Destination      = destination;
     this.ErrorDescription = errorDescripion;
 }
 public GetScoresFinishedEvent(Provider provider, Leaderboard from, SocialPageData <Score> scores, string payload)
     : base(provider, payload)
 {
     this.From   = from;
     this.Scores = scores;
 }
Esempio n. 26
0
		/// <summary>
		/// Handles an <c>onGetScoresStarted</c> event
		/// </summary>
		/// <param name="message">
		/// Will contain a numeric representation of <c>Provider</c>,
		/// and payload</param>
		public void onGetScoresStarted(String message) {
			SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onGetScoresStarted");

			JSONObject eventJson = new JSONObject(message);

			Provider provider = Provider.fromInt ((int)eventJson["provider"].n);
			bool fromStart = eventJson["fromStart"].b;
			Leaderboard owner = new Leaderboard(eventJson["leaderboard"]);
			JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

			ProfileEvents.OnGetScoresStarted(new GetScoresStartedEvent(provider, owner, fromStart, ProfilePayload.GetUserPayload(payloadJSON)));
		}
 public ReportScoreStartedEvent(Provider provider, Leaderboard destination, string payload)
     : base(provider, payload)
 {
     this.Destination = destination;
 }
Esempio n. 28
0
		/// <summary>
		/// Handles an <c>onSubmitScoreFailed</c> event
		/// </summary>
		/// <param name="message">
		/// Will contain a numeric representation of <c>Provider</c>,
		/// and payload</param>
		public void onSubmitScoreFailed(String message) {
			SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSubmitScoreFailed");

			JSONObject eventJson = new JSONObject(message);

			Provider provider = Provider.fromInt ((int)eventJson["provider"].n);
			Leaderboard owner = new Leaderboard(eventJson["leaderboard"]);
			String errorMessage = eventJson["message"].str;

			JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

			ProfileEvents.OnSubmitScoreFailed(new SubmitScoreFailedEvent(provider, owner, errorMessage, ProfilePayload.GetUserPayload(payloadJSON)));
		}
Esempio n. 29
0
 public abstract void ReportScore(Leaderboard owner, int value, SingleObjectSuccess <Score> success, FailureHandler fail);