Exemplo n.º 1
0
        /// <summary>
        /// Brings up the default Game Center interface.
        /// Available in iOS 6.0 and later.
        /// </summary>
        public static void ShowGameCenter()
        {
            var vc = new GKGameCenterViewController();

            vc.gameCenterDelegate = GameCenterControllerDelegate.instance;

            UIApplication.deviceRootViewController.PresentViewController(vc, true, null);
        }
Exemplo n.º 2
0
        void ShowGameCenter()
        {
            GKGameCenterViewController controller = new GKGameCenterViewController();

            controller.Finished += (object sender, EventArgs e) => {
                controller.DismissViewController(true, null);
            };
            AppDelegate.Shared.ViewController.PresentViewController(controller, true, null);
        }
		public async Task ShowAchievements()
		{
			if (showAchievementsTask != null) {
				showAchievementsTask.TrySetResult (false);
				showAchievementsTask.TrySetCanceled ();
			}
			showAchievementsTask = new TaskCompletionSource<bool> ();
			GKGameCenterViewController gcViewController = new GKGameCenterViewController ();
			gcViewController.Delegate = this;
			gcViewController.ViewState = GKGameCenterViewControllerState.Achievements;
			UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (gcViewController, true, null);
			await Task.WhenAll (showAchievementsTask.Task);
		}
        /// <summary>
        /// Shows a default/system view of the games achievements.
        /// </summary>
        /// <returns>
        /// <c>true</c> if the view has been shown; otherwise, <c>false</c>.
        /// </returns>
        public async Task <bool> ShowAchievements()
        {
            var gameCenterController = new GKGameCenterViewController();

            gameCenterController.ViewState = GKGameCenterViewControllerState.Achievements;
            gameCenterController.Finished += (sender, e) =>
            {
                gameCenterController.DismissViewController(true, delegate { });
            };

            await this.view.PresentViewControllerAsync(gameCenterController, true);

            return(true);
        }
		public async Task ShowLeaderboard (string identifier)
		{
			if (showLeaderboardTask != null) {
				showLeaderboardTask.TrySetResult (false);
				showLeaderboardTask.TrySetCanceled ();
			}
			showLeaderboardTask = new TaskCompletionSource<bool> ();
			GKGameCenterViewController gcViewController = new GKGameCenterViewController ();
			gcViewController.Delegate = this;
			gcViewController.ViewState = GKGameCenterViewControllerState.Leaderboards;
			gcViewController.LeaderboardIdentifier = identifier;
			UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (gcViewController, true, null);
			await Task.WhenAll (showLeaderboardTask.Task);
		}
        /// <summary>
        /// Shows a default/system view of the given game leaderboard.
        /// </summary>
        /// <param name="leaderboardCode">The leaderboard code.</param>
        /// <returns>
        /// <c>true</c> if the view has been shown; otherwise, <c>false</c>.
        /// </returns>
        public async Task <bool> ShowLeaderboard(string leaderboardCode)
        {
            var gameCenterController = new GKGameCenterViewController();

            gameCenterController.ViewState             = GKGameCenterViewControllerState.Leaderboards;
            gameCenterController.LeaderboardCategory   = leaderboardCode;
            gameCenterController.LeaderboardIdentifier = leaderboardCode;
            gameCenterController.Finished += (sender, e) =>
            {
                gameCenterController.DismissViewController(true, delegate { });
            };

            await this.view.PresentViewControllerAsync(gameCenterController, true);

            return(true);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Displays the Game Center Achievements interface.
        /// </summary>
        public static void ShowAchievements()
        {
            if (GKGameCenterViewController.ClassExists)
            {
                // ios 6 preferred method
                var gcvc = new GKGameCenterViewController();
                gcvc.gameCenterDelegate = GameCenterControllerDelegate.instance;
                gcvc.viewState          = GKGameCenterViewControllerState.Achievements;

                UIApplication.deviceRootViewController.PresentViewController(gcvc, true, null);
            }
            else
            {
                var avc = new GKAchievementViewController();
                avc.achievementDelegate = AchievementViewControllerDelegate.instance;

                UIApplication.deviceRootViewController.PresentViewController(avc, true, null);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Displays the Game Center Leaderboard interface.
        /// </summary>
        /// <param name="leaderboardID">The ID of the leaderboard to be displayed.</param>
        public static void ShowLeaderboard(string leaderboardID)
        {
            if (GKGameCenterViewController.ClassExists)
            {
                // ios 6 preferred method
                var gcvc = new GKGameCenterViewController();
                gcvc.gameCenterDelegate   = GameCenterControllerDelegate.instance;
                gcvc.viewState            = GKGameCenterViewControllerState.Leaderboards;
                gcvc.leaderboardTimeScope = GKLeaderboardTimeScope.Today;
                gcvc.leaderboardCategory  = leaderboardID;

                UIApplication.deviceRootViewController.PresentViewController(gcvc, true, null);
            }
            else
            {
                var lbvc = new GKLeaderboardViewController();
                lbvc.leaderboardDelegate = LeaderboardViewControllerDelegate.instance;
                lbvc.timeScope           = GKLeaderboardTimeScope.Today;
                lbvc.category            = leaderboardID;

                UIApplication.deviceRootViewController.PresentViewController(lbvc, true, null);
            }
        }
Exemplo n.º 9
0
        public static void ShowAchievements()
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                if (osVersion < 6.0d)
                {
                    // GKAchievementViewController for iOS 5 and older
                    var achievementController = new GKAchievementViewController();
                    achievementController.DidFinish += delegate(object sender, EventArgs e)
                    {
                        HideViewController(achievementController);
                    };

                    ShowViewController(achievementController);
                }
                else
                {
                    // GKGameCenterViewController for iOS 6+
                    var gameCenterController = new GKGameCenterViewController();
                    gameCenterController.Finished += delegate(object sender, EventArgs e)
                    {
                        HideViewController(gameCenterController);
                    };

                    gameCenterController.ViewState = GKGameCenterViewControllerState.Achievements;
                    ShowViewController(gameCenterController);
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", "You must be signed in to Game Center to view achievements.", null, "OK");
                alert.Show();
                ShowSignIn(1, true);
            }
        }
Exemplo n.º 10
0
        public static void ShowLeaderboard()
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
                {
                    // GKLeaderboardViewController for iOS 5 and older
                    var leaderboardController = new GKLeaderboardViewController();
                    leaderboardController.DidFinish += delegate(object sender, EventArgs e)
                    {
                        HideViewController(leaderboardController);
                    };

                    ShowViewController(leaderboardController);
                }
                else
                {
                    // GKGameCenterViewController for iOS 6+
                    var gameCenterController = new GKGameCenterViewController();
                    gameCenterController.Finished += delegate(object sender, EventArgs e)
                    {
                        HideViewController(gameCenterController);
                    };

                    gameCenterController.ViewState = GKGameCenterViewControllerState.Leaderboards;
                    ShowViewController(gameCenterController);
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", "You must be signed in to Game Center to view leaderboards.", null, "OK");
                alert.Show();
                ShowSignIn(1, true);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Displays the Game Center Leaderboard interface.
        /// </summary>
        /// <param name="leaderboardID">The ID of the leaderboard to be displayed.</param>
        public static void ShowLeaderboard(string leaderboardID)
        {
            if (GKGameCenterViewController.ClassExists) {
                // ios 6 preferred method
                var gcvc = new GKGameCenterViewController();
                gcvc.gameCenterDelegate = GameCenterControllerDelegate.instance;
                gcvc.viewState = GKGameCenterViewControllerState.Leaderboards;
                gcvc.leaderboardTimeScope = GKLeaderboardTimeScope.Today;
                gcvc.leaderboardCategory = leaderboardID;

                UIApplication.SharedApplication().keyWindow.rootViewController.PresentViewController(gcvc, true, null);

            } else {
                var lbvc = new GKLeaderboardViewController();
                lbvc.leaderboardDelegate = LeaderboardViewControllerDelegate.instance;
                lbvc.timeScope = GKLeaderboardTimeScope.Today;
                lbvc.category = leaderboardID;

                UIApplication.SharedApplication().keyWindow.rootViewController.PresentViewController(lbvc, true, null);
            }
        }
		public void Finished (GKGameCenterViewController controller)
		{
			if (showLeaderboardTask != null) {
				showLeaderboardTask.TrySetResult (true);
			}
			if(showAchievementsTask != null){
				showAchievementsTask.TrySetResult (true);
			}
			controller.DismissViewController (true, null);
		}
Exemplo n.º 13
0
        public override void TouchesBegan(NSSet touches, UIEvent evt)
        {
            foreach (var touch in touches)
            {
                CGPoint location = (touch as UITouch).LocationInNode(this);
                if (newGame.Frame.Contains(location))
                {
                    PresentScene(new LevelsScene(Size));
                }
                if (leaderBoardsButton.Frame.Contains(location))
                {
                    GKGameCenterViewController controller = new GKGameCenterViewController();
                    controller.Finished += (object sender, EventArgs e) => {
                        controller.DismissViewController(true, null);
                    };
                    controller.LeaderboardCategory  = "com.commtech.inapppurchTest.StageScores";
                    controller.LeaderboardTimeScope = GKLeaderboardTimeScope.AllTime;
                    Scene.View.Window.RootViewController.PresentModalViewController(controller, true);


                    //AppDelegate.
                    //AppDelegate.Shared.ViewController.PresentViewController (controller, true, null);
                }

//				if(unlocked.Frame.Contains(location)){
//
//					PresentScene(new UnlockScene(Size));
//
//				}
                if (snaps.Frame.Contains(location))
                {
//					imgPckr =  new UIImagePickerController ();
//					imgPckr.Delegate = imgPckr;
//					imgPckr.AllowsEditing = true;
//					imgPckr.SourceType = UIImagePickerControllerSourceType.Camera;
//					imgPckr.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
//					imgPckr.FinishedPickingMedia += Handle_FinishedPickingMedia;
//					Scene.View.Window.RootViewController.PresentModalViewController (imgPckr, true);
//
//

                    PresentScene(new SelectaScene(Size));
                }

                if (highScoreButton.Frame.Contains(location))
                {
                    PresentScene(new ScoresScene(Size));
                }

                if (rate.Frame.Contains(location))
                {
                }
                if (share.Frame.Contains(location))
                {
                    actionSheet = new UIActionSheet("Share this App");
                    //actionSheet.AddButton ("Delete");
                    actionSheet.AddButton("Cancel");
                    actionSheet.AddButton("Facebook");
                    actionSheet.AddButton("Twitter");
                    actionSheet.AddButton("Email");

                    actionSheet.AddButton("SMS");

                    //actionSheet.DestructiveButtonIndex = 0; // red
                    actionSheet.CancelButtonIndex = 0;                      // black
                    actionSheet.Clicked          += delegate(object a, UIButtonEventArgs b) {
                        Console.WriteLine("Button " + b.ButtonIndex.ToString() + " clicked");


                        if (b.ButtonIndex == 1)
                        {
                            //facebook
                        }
                        else if (b.ButtonIndex == 2)
                        {
                            //twitter

                            shareTwitter();
                        }
                        else if (b.ButtonIndex == 3)
                        {
                            //email
                            //UIApplication.SharedApplication.OpenUrl(new NSUrl("http://www.google.com/"));


                            shareEmail();
                        }
                        else if (b.ButtonIndex == 4)
                        {
                            //sms

                            shareText();

//							var smsTo = NSUrl.FromString("sms:18015551234");
//
//							UIApplication.SharedApplication.OpenUrl(smsTo);
//							var imessageTo = NSUrl.FromString("sms:[email protected]");
//							UIApplication.SharedApplication.OpenUrl(imessageTo);
//
//							var smsTo1 = NSUrl.FromString("sms:18015551234");
//							if (UIApplication.SharedApplication.CanOpenUrl(smsTo1)) {
//								UIApplication.SharedApplication.OpenUrl(smsTo1);
//							} else {
//								// warn the user, or hide the button...
//							}
                        }
                    };

                    actionSheet.ShowInView(View);
                }
            }
        }
Exemplo n.º 14
0
		void ShowGameCenter ()
		{
			GKGameCenterViewController controller = new GKGameCenterViewController ();
			controller.Finished += (object sender, EventArgs e) => {
				controller.DismissViewController (true, null);
			};
			AppDelegate.Shared.ViewController.PresentViewController (controller, true, null);
		}
Exemplo n.º 15
0
 /// <summary>
 /// Shows the leader board and achievments modal popup.
 /// </summary>
 public static void ShowLeaderBoardAndAchievements()
 {
     if (GKLocalPlayer.LocalPlayer.Authenticated) {
         GKGameCenterViewController gameCenterViewController = new GKGameCenterViewController ();
         gameCenterViewController.ViewState = GKGameCenterViewControllerState.Achievements;
         gameCenterViewController.Delegate = new LeaderBoardDelegate ();
         UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController (gameCenterViewController, true, null);
     }
 }
Exemplo n.º 16
0
 public override void Finished(GKGameCenterViewController controller)
 {
     controller.DismissViewController (true, null);
 }
Exemplo n.º 17
0
        public static void ShowAchievements()
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
                {
                    // GKAchievementViewController for iOS 5 and older
                    var achievementController = new GKAchievementViewController();
                    achievementController.DidFinish += delegate(object sender, EventArgs e)
                    {
                        HideViewController(achievementController);
                    };

                    ShowViewController(achievementController);
                }
                else
                {
                    // GKGameCenterViewController for iOS 6+
                    var gameCenterController = new GKGameCenterViewController();
                    gameCenterController.Finished += delegate(object sender, EventArgs e)
                    {
                        HideViewController(gameCenterController);
                    };

                    gameCenterController.ViewState = GKGameCenterViewControllerState.Achievements;
                    ShowViewController(gameCenterController);
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", "You must be signed in to Game Center to view achievements.", null, "OK");
                alert.Show();
                ShowSignIn(1, true);
            }
        }
 public override void DidFinish(GKGameCenterViewController gameCenterViewController)
 {
     gameCenterViewController.presentingViewController.DismissViewController(true, null);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Displays the Game Center Achievements interface.
        /// </summary>
        public static void ShowAchievements()
        {
            if (GKGameCenterViewController.ClassExists) {
                // ios 6 preferred method
                var gcvc = new GKGameCenterViewController();
                gcvc.gameCenterDelegate = GameCenterControllerDelegate.instance;
                gcvc.viewState = GKGameCenterViewControllerState.Achievements;

                UIApplication.SharedApplication().keyWindow.rootViewController.PresentViewController(gcvc, true, null);

            } else {
                var avc = new GKAchievementViewController();
                avc.achievementDelegate = AchievementViewControllerDelegate.instance;

                UIApplication.SharedApplication().keyWindow.rootViewController.PresentViewController(avc, true, null);
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// Brings up the default Game Center interface.
        /// Available in iOS 6.0 and later.
        /// </summary>
        public static void ShowGameCenter()
        {
            var vc = new GKGameCenterViewController();

            vc.gameCenterDelegate = GameCenterControllerDelegate.instance;

            UIApplication.SharedApplication().keyWindow.rootViewController.PresentViewController(vc, true, null);
        }
Exemplo n.º 21
0
 public override void DidFinish(GKGameCenterViewController gameCenterViewController)
 {
     gameCenterViewController.presentingViewController.DismissViewController(true, null);
 }
Exemplo n.º 22
0
        /// <summary>
        /// Brings up the default Game Center interface.
        /// Available in iOS 6.0 and later.
        /// </summary>
        public static void ShowGameCenter()
        {
            var vc = new GKGameCenterViewController();

            vc.gameCenterDelegate = GameCenterControllerDelegate.instance;

            UIApplication.deviceRootViewController.PresentViewController(vc, true, null);
        }