void ShowGameCenter() { GKGameCenterViewController controller = new GKGameCenterViewController(); controller.Finished += (object sender, EventArgs e) => { controller.DismissViewController(true, null); }; AppDelegate.Shared.ViewController.PresentViewController(controller, true, null); }
/// <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); }
/// <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); }
public void Finished (GKGameCenterViewController controller) { if (showLeaderboardTask != null) { showLeaderboardTask.TrySetResult (true); } if(showAchievementsTask != null){ showAchievementsTask.TrySetResult (true); } controller.DismissViewController (true, null); }
void ShowGameCenter () { GKGameCenterViewController controller = new GKGameCenterViewController (); controller.Finished += (object sender, EventArgs e) => { controller.DismissViewController (true, null); }; AppDelegate.Shared.ViewController.PresentViewController (controller, true, null); }
public override void Finished(GKGameCenterViewController controller) { controller.DismissViewController (true, null); }
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); } } }