Esempio n. 1
0
        /// <summary>
        /// Shows guide view controllers, e.g., Game Center view controllers.
        /// In iOS 5 and older, the guide is presented using GuideViewController.
        /// In iOS 6+, the guide is presented using the root view controller.
        /// (The iOS 5 method generates runtime warnings.)
        /// </summary>
        /// <param name="viewController">The view controller to be shown, e.g., Game Center view controllers</param>
        private static void ShowViewController(UIViewController viewController)
        {
            if (_window != null && viewController != null)
            {
                prevGestures = TouchPanel.EnabledGestures;
                TouchPanel.EnabledGestures = GestureType.None;

                if (osVersion < 6.0d)
                {
                    // Show view controller the old way for iOS 5 and older
                    if (guideViewController == null)
                    {
                        guideViewController = new GuideViewController(_gameViewController);
                        _window.Add(guideViewController.View);
                        guideViewController.View.Hidden = true;
                    }

#pragma warning disable 618
                    // Disable PresentModalViewController warning, still need to support iOS 5 and older
                    guideViewController.PresentModalViewController(viewController, true);
#pragma warning restore 618
                }
                else
                {
                    // Show view controller the new way for iOS 6+
                    _window.RootViewController.PresentViewController(viewController, true, delegate {});
                }

                IsVisible = true;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Displays the iOS matchmaker to the player.
        /// </summary>
        /// <remarks>
        /// Note this is not overloaded in derived classes on purpose.  This is
        /// only a reason this exists is for caching effects.
        /// </remarks>
        /// <param name="minPlayers">Minimum players to find</param>
        /// <param name="maxPlayers">Maximum players to find</param>
        /// <param name="playersToInvite">Players to invite/param>
        public static void ShowMatchMaker(int minPlayers, int maxPlayers, string[] playersToInvite)
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                // Lazy load it
                if (matchmakerViewController == null)
                {
                    matchmakerViewController = new GKMatchmakerViewController(new GKMatchRequest());
                }

                if (matchmakerViewController != null)
                {
                    matchmakerViewController.MatchRequest.MinPlayers      = minPlayers;
                    matchmakerViewController.MatchRequest.MaxPlayers      = maxPlayers;
                    matchmakerViewController.MatchRequest.PlayersToInvite = playersToInvite;

                    matchmakerViewController.DidFailWithError += delegate(object sender, GKErrorEventArgs e) {
                        matchmakerViewController.DismissModalViewControllerAnimated(true);
                        IsVisible = false;
                        TouchPanel.EnabledGestures = prevGestures;
                    };

                    matchmakerViewController.DidFindMatch += delegate(object sender, GKMatchEventArgs e) {
                        Guide.Match = e.Match;
                    };

                    matchmakerViewController.DidFindPlayers += delegate(object sender, GKPlayersEventArgs e) {
                    };

                    matchmakerViewController.WasCancelled += delegate(object sender, EventArgs e) {
                        matchmakerViewController.DismissModalViewControllerAnimated(true);
                        IsVisible = false;
                        TouchPanel.EnabledGestures = prevGestures;
                    };

                    if (_window != null)
                    {
                        if (viewController == null)
                        {
                            viewController = new GuideViewController(_gameViewController);
                            _window.Add(viewController.View);
                            viewController.View.Hidden = true;
                        }

                        prevGestures = TouchPanel.EnabledGestures;
                        TouchPanel.EnabledGestures = GestureType.None;
                        viewController.PresentModalViewController(matchmakerViewController, true);
                        IsVisible = true;
                    }
                }
            }
        }
Esempio n. 3
0
        public static void ShowAchievements()
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                // Lazy load it
                if (achievementController == null)
                {
                    achievementController = new GKAchievementViewController();
                }

                if (achievementController != null)
                {
                    achievementController.DidFinish += delegate(object sender, EventArgs e)
                    {
                        achievementController.DismissModalViewControllerAnimated(true);
                        IsVisible = false;
                        TouchPanel.EnabledGestures = prevGestures;
                    };

                    if (_window != null)
                    {
                        if (viewController == null)
                        {
                            viewController = new GuideViewController(_gameViewController);
                            _window.Add(viewController.View);
                            viewController.View.Hidden = true;
                        }

                        prevGestures = TouchPanel.EnabledGestures;
                        TouchPanel.EnabledGestures = GestureType.None;
                        viewController.PresentModalViewController(achievementController, true);
                        IsVisible = true;
                    }
                }
            }
            else
            {
                UIAlertView alert = new UIAlertView("Error", "You need to be logged into Game Center to view Achievements.", null, "Ok");
                alert.Show();
                ShowSignIn(1, true);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Displays the iOS matchmaker to the player.
        /// </summary>
        /// <remarks>
        /// Note this is not overloaded in derived classes on purpose.  This is
        /// only a reason this exists is for caching effects.
        /// </remarks>
        /// <param name="minPlayers">Minimum players to find</param>
        /// <param name="maxPlayers">Maximum players to find</param>
        /// <param name="playersToInvite">Players to invite/param>
        public static void ShowMatchMaker(int minPlayers, int maxPlayers, string[] playersToInvite)
		{
			AssertInitialised ();

			if ( ( Gamer.SignedInGamers.Count > 0 ) && ( Gamer.SignedInGamers[0].IsSignedInToLive ) )
			{
				// Lazy load it
				if ( matchmakerViewController == null )
				{
					matchmakerViewController = new GKMatchmakerViewController(new GKMatchRequest());
				}

			    if (matchmakerViewController != null)		
			    {		
                    matchmakerViewController.MatchRequest.MinPlayers = minPlayers;
                    matchmakerViewController.MatchRequest.MaxPlayers = maxPlayers;
                    matchmakerViewController.MatchRequest.PlayersToInvite = playersToInvite;

					matchmakerViewController.DidFailWithError += delegate(object sender, GKErrorEventArgs e) {
						matchmakerViewController.DismissModalViewControllerAnimated(true);
						IsVisible = false;
						TouchPanel.EnabledGestures=prevGestures;
					};
					
					matchmakerViewController.DidFindMatch += delegate(object sender, GKMatchEventArgs e) {
                        Guide.Match = e.Match;
					};
						
					matchmakerViewController.DidFindPlayers += delegate(object sender, GKPlayersEventArgs e) {
						
					};
					
					matchmakerViewController.WasCancelled += delegate(object sender, EventArgs e) {
						matchmakerViewController.DismissModalViewControllerAnimated(true);
						IsVisible = false;
						TouchPanel.EnabledGestures=prevGestures;
					};

					if (_window != null)
					{
						if(viewController == null)
						{
                            viewController = new GuideViewController(_gameViewController);
							_window.Add(viewController.View);
							viewController.View.Hidden = true;
						}

						prevGestures=TouchPanel.EnabledGestures;
						TouchPanel.EnabledGestures=GestureType.None;
						viewController.PresentModalViewController(matchmakerViewController, true);						
						IsVisible = true;
					}				
			    }
			}
		}
Esempio n. 5
0
		public static void ShowAchievements()
		{
			AssertInitialised ();

			if ( ( Gamer.SignedInGamers.Count > 0 ) && ( Gamer.SignedInGamers[0].IsSignedInToLive ) )
			{
				// Lazy load it
				if ( achievementController == null )
				{
					achievementController = new GKAchievementViewController();
				}

			    if (achievementController != null)		
			    {					
					achievementController.DidFinish += delegate(object sender, EventArgs e) 
					{									 
						achievementController.DismissModalViewControllerAnimated(true);
						IsVisible = false;
						TouchPanel.EnabledGestures=prevGestures;
					};

					if (_window != null)
					{
						if(viewController == null)
						{
                            viewController = new GuideViewController(_gameViewController);
							_window.Add(viewController.View);
							viewController.View.Hidden = true;
						}

						prevGestures=TouchPanel.EnabledGestures;
						TouchPanel.EnabledGestures=GestureType.None;
						viewController.PresentModalViewController(achievementController, true);						
						IsVisible = true;
					}
			    }
			}
			else
			{
				UIAlertView alert = new UIAlertView("Error","You need to be logged into Game Center to view Achievements.",null,"Ok");
				alert.Show();
				ShowSignIn(1,true);
			}
		}
Esempio n. 6
0
        /// <summary>
        /// Shows guide view controllers, e.g., Game Center view controllers.
        /// In iOS 5 and older, the guide is presented using GuideViewController.
        /// In iOS 6+, the guide is presented using the root view controller.
        /// (The iOS 5 method generates runtime warnings.)
        /// </summary>
        /// <param name="viewController">The view controller to be shown, e.g., Game Center view controllers</param>
        private static void ShowViewController(UIViewController viewController)
        {
            if (_window != null && viewController != null)
            {
                prevGestures = TouchPanel.EnabledGestures;
                TouchPanel.EnabledGestures = GestureType.None;

                if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0))
                {
                    // Show view controller the old way for iOS 5 and older
                    if (guideViewController == null)
                    {
                        guideViewController = new GuideViewController(_gameViewController);
                        _window.Add(guideViewController.View);
                        guideViewController.View.Hidden = true;
                    }

#pragma warning disable 618
                    // Disable PresentModalViewController warning, still need to support iOS 5 and older
                    guideViewController.PresentModalViewController(viewController, true);
#pragma warning restore 618
                }
                else
                {
                    // Show view controller the new way for iOS 6+
                    _window.RootViewController.PresentViewController(viewController, true, delegate {});
                }

                IsVisible = true;
            }
        }