Ejemplo n.º 1
0
        public void DoAwardAchievement(string achievementId, double percentageComplete)
        {
            GKAchievement a = new GKAchievement(achievementId);

            a.PercentComplete = percentageComplete;
            a.ReportAchievement(delegate(NSError error){
                if (error != null)
                {
                    // Retain the achievement object and try again later (not shown).
                }
            });
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reports the progress of an achivement to Game Center.
        /// The returned GKAchievement can be used for more advanced functionalities such as sending challenges.
        /// Raises AchievementReported and AchievementReportFailed events on completion.
        /// </summary>
        /// <returns>The native achievement.</returns>
        /// <param name="achievementId">The ID of the achievementId to report to.</param>
        /// <param name="percentComplete">The progress from 0.0 to 100.0.</param>
        public static GKAchievement ReportAchievement(string achievementId, double percentComplete)
        {
            var achievement = new GKAchievement(achievementId);

            if (achievement.IsNil)
            {
                return(null);
            }

            achievement.percentComplete = percentComplete;
            achievement.ReportAchievement(_AchievementReported);
            return(achievement);
        }
Ejemplo n.º 3
0
 // Submit an achievement to the server and store if submission fails
 public void submitAchievement(GKAchievement achievement)
 {
     if (achievement != null)
     {
         //submit the achievement
         achievement.ReportAchievement(new GKNotificationHandler((error) => {
             if (error == null)
             {
                 if (storedAchievements.ContainsKey(new NSString(achievement.Identifier)))
                 {
                     storedAchievements.Remove(new NSString(achievement.Identifier));
                 }
                 new UIAlertView("Achievement Submitted", "Achievement submitted successfully ", null, "OK", null).Show();
             }
             else
             {
                 this.storeAchievement(achievement);
                 new UIAlertView("Achievement Stored", "Achievement Stored ", null, "OK", null).Show();
             }
         }));
     }
 }
        private Task <bool> InternalUpdateAchievement(GKAchievement achievement, double value)
        {
            var tcs = new TaskCompletionSource <bool>();

            achievement.PercentComplete = value;
            achievement.ReportAchievement((error) =>
            {
                var result = true;

                if (error != null)
                {
                    result = false;
#if DEBUG
                    new UIAlertView("Achievement submittion failed", "Submittion failed because: " + error, null, "OK", null).Show();
#endif
                }

                tcs.TrySetResult(result);
            });

            return(tcs.Task);
        }
Ejemplo n.º 5
0
        public void DoAwardAchievement(string achievementId, double percentageComplete)
        {
            if (IsSignedInToLive)
            {
                UIApplication.SharedApplication.InvokeOnMainThread(delegate
                {
                    GKAchievement achievement   = new GKAchievement(achievementId);
                    achievement.PercentComplete = percentageComplete;

                    if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
                    {
                        #pragma warning disable 618
                        // Report achievement for iOS 5 and older
                        achievement.ReportAchievement(delegate(NSError error)
                        {
                            if (error != null)
                            {
                                // Oh oh something went wrong.
                            }
                        });
                        #pragma warning restore 618
                    }
                    else
                    {
                        // Report achievement for iOS 6+
                        GKAchievement.ReportAchievements(new GKAchievement[] { achievement }, delegate(NSError error)
                        {
                            if (error != null)
                            {
                                // Oh oh something went wrong.
                            }
                        });
                    }
                });
            }
        }
Ejemplo n.º 6
0
		public void DoAwardAchievement( string achievementId, double percentageComplete )
		{
			GKAchievement a = new GKAchievement(achievementId);
				a.PercentComplete = percentageComplete;
				a.ReportAchievement( delegate(NSError error){
					if (error != null)
					{
						// Retain the achievement object and try again later (not shown).
					}
		
				} );
		}
		// Submit an achievement to the server and store if submission fails
		public void submitAchievement (GKAchievement achievement)
		{
			if (achievement != null) {
				//submit the achievement
				achievement.ReportAchievement (new Action<NSError> ((error) => {
					if (error == null) {
						if (storedAchievements.ContainsKey (new NSString (achievement.Identifier)))
							storedAchievements.Remove (new NSString (achievement.Identifier));
						new UIAlertView ("Achievement Submitted", "Achievement submitted successfully ", null, "OK", null).Show ();
					} else {
						this.storeAchievement (achievement);
						new UIAlertView ("Achievement Stored", "Achievement Stored ", null, "OK", null).Show ();
					}
				}));
			}
		}
Ejemplo n.º 8
0
        public void DoAwardAchievement(string achievementId, double percentageComplete)
        {
            if (IsSignedInToLive)
            {
                UIApplication.SharedApplication.InvokeOnMainThread(delegate
                {
                    GKAchievement achievement = new GKAchievement(achievementId);
                    achievement.PercentComplete = percentageComplete;

                    if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
                    {
                        #pragma warning disable 618
                        // Report achievement for iOS 5 and older
                        achievement.ReportAchievement(delegate(NSError error)
                        {
                            if (error != null)
                            {
                                // Oh oh something went wrong.
                            }
                        });
                        #pragma warning restore 618
                    }
                    else
                    {
                        // Report achievement for iOS 6+
                        GKAchievement.ReportAchievements(new GKAchievement[] { achievement }, delegate (NSError error)
                        {
                            if (error != null)
                            {
                                // Oh oh something went wrong.
                            }
                        });
                    }
                });
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Reports the progress of an achivement to Game Center.
        /// The returned GKAchievement can be used for more advanced functionalities such as sending challenges.
        /// Raises AchievementReported and AchievementReportFailed events on completion.
        /// </summary>
        /// <returns>The native achievement.</returns>
        /// <param name="achievementId">The ID of the achievementId to report to.</param>
        /// <param name="percentComplete">The progress from 0.0 to 100.0.</param>
        public static GKAchievement ReportAchievement(string achievementId, double percentComplete)
        {
            var achievement = new GKAchievement(achievementId);
            if (achievement.IsNil)
                return null;

            achievement.percentComplete = percentComplete;
            achievement.ReportAchievement(_AchievementReported);
            return achievement;
        }