The screen manager is a component which manages one or more GameScreen instances. It maintains a stack of screens, calls their Update and Draw methods at the appropriate times, and automatically routes input to the topmost active screen.
コード例 #1
1
		/// <summary>
		/// The constructor is private: loading screens should
		/// be activated via the static Load method instead.
		/// </summary>
		private LoadingScreen (ScreenManager screenManager,bool loadingIsSlow, 
				GameScreen[] screensToLoad)
			{
			this.loadingIsSlow = loadingIsSlow;
			this.screensToLoad = screensToLoad;

			TransitionOnTime = TimeSpan.FromSeconds (0.5);

			// If this is going to be a slow load operation, create a background
			// thread that will update the network session and draw the load screen
			// animation while the load is taking place.
			if (loadingIsSlow) {
				backgroundThread = new Thread (BackgroundWorkerThread);
				backgroundThreadExit = new ManualResetEvent (false);

				graphicsDevice = screenManager.GraphicsDevice;

				// Look up some services that will be used by the background thread.
				IServiceProvider services = screenManager.Game.Services;

				networkSession = (NetworkSession)services.GetService (
							typeof(NetworkSession));

				messageDisplay = (IMessageDisplay)services.GetService (
							typeof(IMessageDisplay));
			}
		}
コード例 #2
0
		public CatapultGame ()
		{
			graphics = new GraphicsDeviceManager (this);
			//graphics.SynchronizeWithVerticalRetrace = false;
			Content.RootDirectory = "Content";

			// Frame rate is 30 fps by default for Windows Phone.
			TargetElapsedTime = TimeSpan.FromTicks (333333);

			//Create a new instance of the Screen Manager
			screenManager = new ScreenManager (this);
			
			Components.Add (screenManager);

			Components.Add (new MessageDisplayComponent (this));
			Components.Add (new GamerServicesComponent (this));
			
			//Add two new screens
			screenManager.AddScreen (new BackgroundScreen (), null);
			screenManager.AddScreen (new MainMenuScreen (), null);

			// Listen for invite notification events.
			NetworkSession.InviteAccepted += (sender, e) => NetworkSessionComponent.InviteAccepted (screenManager, e);

			IsMouseVisible = true;
#if !WINDOWS && !XBOX && !MONOMAC && !LINUX
			//Switch to full screen for best game experience
			graphics.IsFullScreen = true;
#else
            graphics.PreferredBackBufferHeight = 480;
            graphics.PreferredBackBufferWidth = 800;
#endif
			AudioManager.Initialize (this);
		}
コード例 #3
0
        /// <summary>
        /// The main game constructor
        /// </summary>
        public MadLabGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            this.TargetElapsedTime = TimeSpan.FromSeconds(1.0f / 60f);

            // Setup window
            Window.Title = "MadLab";
            graphics.PreferredBackBufferWidth = GameConstants.X_RESOLUTION;
            graphics.PreferredBackBufferHeight = GameConstants.Y_RESOLUTION;
            graphics.IsFullScreen = false;
            graphics.ApplyChanges();

            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            // component for screenManager
            Components.Add(screenManager);

            # if(XBOX)
            Components.Add(new GamerServicesComponent(this));
            #endif
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the game.
        /// </summary>
        public BlackjackGame()
        {
            graphics = new GraphicsDeviceManager(this);

            Content.RootDirectory = "Content";

            screenManager = new ScreenManager(this);

            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            Components.Add(screenManager);

            #if WINDOWS || MACOS || LINUX
            IsMouseVisible = true;
            #elif WINDOWS_PHONE || IOS || ANDROID
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            graphics.IsFullScreen = true;
            #else
            Components.Add(new GamerServicesComponent(this));
            #endif

            // Initialize sound system
            AudioManager.Initialize(this);
        }
コード例 #5
0
ファイル: CatapultGame.cs プロジェクト: elixir67/Sandbox
        public CatapultGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            //Create a new instance of the Screen Manager
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            //Switch to full screen for best game experience
            graphics.IsFullScreen = true;

            //Add two new screens
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            //Create Chooser and Launcher
            InitializeChooserAndLauncher();

            AudioManager.Initialize(this);
            InitializePhoneServices();
        }
コード例 #6
0
ファイル: Game.cs プロジェクト: lioralterman/xnapacman
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            instance = this;

            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            //graphics.PreferredBackBufferWidth = 853;
            //graphics.PreferredBackBufferHeight = 480;

            graphics.PreferredBackBufferWidth = 640;
            graphics.PreferredBackBufferHeight = 480;
            //graphics.IsFullScreen = true;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            contentManager = new ContentManager(screenManager.Game.Services, "Content");

            SoundManager.contentManager = content;
            SoundManager.LoadContent();

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);
        }
コード例 #7
0
ファイル: Game.cs プロジェクト: kubakista/Battle-City
        public Game1()
        {
            // jazyk
            Thread.CurrentThread.CurrentUICulture	=	CultureInfo.GetCultureInfo("cs-CZ");

            this.graphics	=	new GraphicsDeviceManager(this);

            // rozmìry okna
            this.graphics.PreferredBackBufferWidth	=	733;
            this.graphics.PreferredBackBufferHeight	=	608;

            this.Content.RootDirectory	=	"Content";

            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            this.AddInitialScreens();
        }
コード例 #8
0
        /// <summary>
        /// Initializes a new instance of the game.
        /// </summary>
        public BlackjackGame()
        {
            graphics = new GraphicsDeviceManager(this);
            
            Content.RootDirectory = "Content";

            screenManager = new ScreenManager(this);

            screenManager.AddScreen(new BackgroundScreen(), null);
            screenManager.AddScreen(new MainMenuScreen(), null);

            Components.Add(screenManager);

#if WINDOWS
            IsMouseVisible = true;
#elif WINDOWS_PHONE
            // Frame rate is 30 fps by default for Windows Phone.
            TargetElapsedTime = TimeSpan.FromTicks(333333);
            graphics.IsFullScreen = true;
#else
            Components.Add(new GamerServicesComponent(this));
#endif

            // Initialize sound system
            AudioManager.Initialize(this);
#if XBOX
            graphics.PreferredBackBufferHeight = graphics.GraphicsDevice.DisplayMode.Height;
            graphics.PreferredBackBufferWidth = graphics.GraphicsDevice.DisplayMode.Width; 
#elif WINDOWS
            graphics.PreferredBackBufferHeight = 480;
            graphics.PreferredBackBufferWidth = 800; 
#endif        
        }
コード例 #9
0
 public static void Load(ScreenManager screenManager, bool loadingIsSlow, params GameScreen[] screensToLoad)
 {
     foreach (GameScreen screen in screenManager.GetScreens())
         screen.ExitScreen();
     LoadingScreen loadingScreen = new LoadingScreen(screenManager, loadingIsSlow, screensToLoad);
     screenManager.AddScreen(loadingScreen);
 }
コード例 #10
0
        public static string insertLineBreaks(string post, float maxSize, ScreenManager MyScreenManager)
        {
            float maxSizeScaled = maxSize * SpriteDrawer.drawScale.X;
            string result = "";
            string wordToAdd = "";
            string tryAdd;
            foreach (char c in post) {
                if (c == ' ') {
                    // this char is a white space. word to add contains the next word to add
                    tryAdd = result + (result == "" ? "" : " ") + wordToAdd;
                    if (MyScreenManager.Fonts["tahoma"].MeasureString(tryAdd).X < maxSizeScaled) {
                        result = tryAdd;
                    } else {
                        result += "\n" + wordToAdd;
                    }
                    wordToAdd = "";
                } else {
                    // keep building our word
                    wordToAdd += c;
                }
            }

            // add the last word
            tryAdd = result + (result == "" ? "" : " ") + wordToAdd;
            if (MyScreenManager.Fonts["tahoma"].MeasureString(tryAdd).X < maxSizeScaled) {
                result = tryAdd;
            } else {
                result += "\n" + wordToAdd;
            }

            return result;
        }
コード例 #11
0
ファイル: Game.cs プロジェクト: TheFerrango/SpotASheep
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
              Content.RootDirectory = "Content";
              graphics.IsFullScreen = true;
              InitializeLandscapeGraphics();
              // Frame rate is 30 fps by default for Windows Phone.
              TargetElapsedTime = TimeSpan.FromTicks(333333);

              // Extend battery life under lock.
              InactiveSleepTime = TimeSpan.FromSeconds(1);

              screenFactory = new ScreenFactory();
              Services.AddService(typeof(IScreenFactory), screenFactory);

              screenManager = new ScreenManager(this);
              Components.Add(screenManager);

              Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
              Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
              new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
              Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
              new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
        }
コード例 #12
0
ファイル: Game.cs プロジェクト: bohesp10/Game
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = true;
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // you can choose whether you want a landscape or portait
            // game by using one of the two helper functions.
            // This game only supports Landscape view, both left and right
            //InitializePortraitGraphics();
            InitializeLandscapeGraphics();
            graphics.SupportedOrientations = DisplayOrientation.LandscapeLeft | DisplayOrientation.LandscapeRight;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            // Note make sure to render in correct order
            Components.Add(screenManager);

            // attempt to deserialize the screen manager from disk. if that
            // fails, we add our default screens.
            if (!screenManager.DeserializeState())
            {
                // Activate the first screens.
                screenManager.AddScreen(new BackgroundScreen(), null);
                screenManager.AddScreen(new MainMenuScreen(), null);
            }
        }
コード例 #13
0
ファイル: Game.cs プロジェクト: wuwenhuang/RobotContra
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            #if WINDOWS_PHONE
            graphics.IsFullScreen = true;

            // Choose whether you want a landscape or portait game by using one of the two helper functions.
            InitializeLandscapeGraphics();
            // InitializePortraitGraphics();
            #endif
            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            #if WINDOWS_PHONE
            // Hook events on the PhoneApplicationService so we're notified of the application's life cycle
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
                new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
                new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
            #else
            // On Windows and Xbox we just add the initial screens
            AddInitialScreens();
            #endif
        }
コード例 #14
0
ファイル: Game.cs プロジェクト: V1ncam/Tetris
        public Game()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            TargetElapsedTime = TimeSpan.FromTicks(333333);

            graphics.IsFullScreen = true;

            graphics.PreferredBackBufferWidth = 480;
            graphics.PreferredBackBufferHeight = 800;

            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            Microsoft.Phone.Shell.PhoneApplicationService.Current.Launching +=
                new EventHandler<Microsoft.Phone.Shell.LaunchingEventArgs>(GameLaunching);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Activated +=
                new EventHandler<Microsoft.Phone.Shell.ActivatedEventArgs>(GameActivated);
            Microsoft.Phone.Shell.PhoneApplicationService.Current.Deactivated +=
                new EventHandler<Microsoft.Phone.Shell.DeactivatedEventArgs>(GameDeactivated);
        }
コード例 #15
0
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);
            graphics.IsFullScreen = true;
            TargetElapsedTime = TimeSpan.FromTicks(333333);

            // you can choose whether you want a landscape or portait
            // game by using one of the two helper functions.
            //InitializePortraitGraphics();
             InitializeLandscapeGraphics();

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // attempt to deserialize the screen manager from disk. if that
            // fails, we add our default screens.
            if (!screenManager.DeserializeState())
            {
                // Activate the first screens.
                screenManager.AddScreen(new MenuBackgroundScreen("mainMenubackground"), null);
                screenManager.AddScreen(new MainMenuScreen(), null);
            }
        }
コード例 #16
0
ファイル: Game.cs プロジェクト: shalynnho/airplane
        /// <summary>
        /// The main game constructor.
        /// </summary>
        public GameStateManagementGame()
        {
            Content.RootDirectory = "Content";

            graphics = new GraphicsDeviceManager(this);

            graphics.PreferredBackBufferWidth = 1024;
            graphics.PreferredBackBufferHeight = 768;

            // Create the screen manager component.
            screenManager = new ScreenManager(this);

            Components.Add(screenManager);

            // Activate the first screens.
            screenManager.AddScreen(new BackgroundScreen());
            screenManager.AddScreen(new MainMenuScreen());

            m_kInfoBox = new Utils.InfoBox(this, new Vector2(Window.ClientBounds.Width, Window.ClientBounds.Height - 10));
            //Components.Add(m_kInfoBox);

            IsFixedTimeStep = true;
            graphics.SynchronizeWithVerticalRetrace = true;

            // For testing purposes, let's disable fixed time step and vsync.
            //IsFixedTimeStep = false;
            //graphics.SynchronizeWithVerticalRetrace = false;
        }
コード例 #17
0
ファイル: GameMain.cs プロジェクト: rossmas/zomination
        SpriteBatch spriteBatch; // this is for FPS counter

        #endregion Fields

        #region Constructors

        public GameMain()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "main";

            #if XBOX
            // Create Gamer Service Component
            SignedInGamer.SignedOut += new EventHandler<SignedOutEventArgs>(SignedInGamer_SignedOut);
            GamerServicesComponent gamerServiceComp = new GamerServicesComponent(this);
            Components.Add(gamerServiceComp);
            #if DEBUG
            Guide.SimulateTrialMode = true;
            #endif
            #endif

            // Create the screen factory and add it to the Services
            screenFactory = new ScreenFactory();
            Services.AddService(typeof(IScreenFactory), screenFactory);

            // Create the screen manager component.
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            // On Windows and Xbox we just add the initial screens
            AddInitialScreens();
        }
コード例 #18
0
ファイル: InputHelper.cs プロジェクト: Clancey/BMX_MonoGame
        /// <summary>
        ///   Constructs a new input state.
        /// </summary>
        public InputHelper(ScreenManager manager)
        {
            _currentKeyboardState = new KeyboardState();
            _currentGamePadState = new GamePadState();
            _currentMouseState = new MouseState();
            _currentVirtualState = new GamePadState();

            _lastKeyboardState = new KeyboardState();
            _lastGamePadState = new GamePadState();
            _lastMouseState = new MouseState();
            _lastVirtualState = new GamePadState();

            _manager = manager;

            _cursorIsVisible = false;
            _cursorMoved = false;
            #if WINDOWS_PHONE
            _cursorIsValid = false;
            #else
            _cursorIsValid = true;
            #endif
            _cursor = Vector2.Zero;

            _handleVirtualStick = false;
        }
コード例 #19
0
ファイル: Game.cs プロジェクト: szyszart/Junkyard
        public Game()
        {
            _graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            _graphics.PreferredBackBufferWidth = PREFERRED_WIDTH;
            _graphics.PreferredBackBufferHeight = PREFERRED_HEIGHT;

            // Krzysztoff has an ancient computer and that's why he needs manual resolution settings
            // If you are lucky enough to have a more powerful machine, feel free to uncomment the following lines.
            _graphics.PreparingDeviceSettings += graphics_PreparingDeviceSettings;
            #if !DEBUG
            _graphics.IsFullScreen = true;
            #endif
            //why was it turned off?
            IsFixedTimeStep = true;
            // disable FPS throttling
            _graphics.SynchronizeWithVerticalRetrace = false;

            _screenFactory = new ScreenFactory();
            Services.AddService(typeof (IScreenFactory), _screenFactory);

            // Create the screen manager component.
            _screenManager = new ScreenManager(this);
            Components.Add(_screenManager);

            IsMouseVisible = false;

            AddInitialScreens();
        }
コード例 #20
0
        private SplashScreenLoading(ScreenManager screenManager, bool loadingIsSlow,
                                MainMenuScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
コード例 #21
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
コード例 #22
0
ファイル: Ragdoll.cs プロジェクト: Clancey/BMX_MonoGame
        public Ragdoll(World world,  ScreenManager manager, Vector2 position)
        {
            CreateBody(world, position);
            CreateJoints(world);

            ScreenManager = manager;
            CreateGFX();
        }
コード例 #23
0
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
            : base(false)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

            EnabledGestures = GestureType.Tap; // Monogame goes on an infinite loop if I don't do this..
        }
コード例 #24
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public GameplayScreen(ScreenManager screenmanager)
 {
     this.ScreenManager = screenmanager;
     TransitionOnTime = TimeSpan.FromSeconds(1.5);
     TransitionOffTime = TimeSpan.FromSeconds(0.5);
     game = ScreenManager.Game;
     physics = new PhysicsSimulator();
     master = new master(physics, game);            
     camera = new camera(game, (int)((float)this.game.GraphicsDevice.Viewport.Height * simplegui.gui_size));
     spritebatch = ScreenManager.SpriteBatch;
 }
コード例 #25
0
ファイル: Constants.cs プロジェクト: Clancey/BMX_MonoGame
 public static void Initialize(ScreenManager screenManager)
 {
     var width = screenManager.GraphicsDevice.Viewport.Width;
     var height = screenManager.GraphicsDevice.Viewport.Height;
     HalfScreenWidth = ScreenWidth / 2f;
     HalfScreenHeight = ScreenHeight / 2f;
     ScreenCenter = new Vector2(HalfScreenWidth,HalfScreenHeight);
     FloorPosition = new Vector2(0, ScreenHeight * 0.875f); // = 7/8
     FloorSize = new Vector2(ScreenWidth,ScreenHeight - FloorPosition.Y);
     WorldWidth =  (ScreenWidth / Scale) * 2f;
 }
コード例 #26
0
ファイル: LoadingScreen.cs プロジェクト: hvp/Squareosity
        /// <summary>
        /// The constructor is private: loading screens should
        /// be activated via the static Load method instead.
        /// </summary>
        private LoadingScreen(ScreenManager screenManager, bool loadingIsSlow,
                              GameScreen[] screensToLoad)
        {
            this.loadingIsSlow = loadingIsSlow;
            this.screensToLoad = screensToLoad;

             rnd = new Random();
             randInt = rnd.Next(3); // 0 to 2

            TransitionOnTime = TimeSpan.FromSeconds(0.5);
        }
コード例 #27
0
        public static void Load(ScreenManager screenManager, bool loadingIsSlow,
                                PlayerIndex? controllingPlayer,
                                params MainMenuScreen[] screensToLoad)
        {
            foreach (GameScreen screen in screenManager.GetScreens())
                screen.ExitScreen();

            SplashScreenLoading splashScreenLoading = new SplashScreenLoading(screenManager, loadingIsSlow, screensToLoad);

            screenManager.AddScreen(splashScreenLoading, controllingPlayer);
        }
コード例 #28
0
        private void AddCustomComponents()
        {
            screenManager = new ScreenManager(this);
            Components.Add(screenManager);

            Components.Add(new VideoCaptureComponent(this));
            Components.Add(new AugmentedRealityComponent(this));
            Components.Add(new ArResultComponent(this));
            Components.Add(new PositionerComponent(this));

            Services.AddService(typeof(IConfigurationService), config);
        }
コード例 #29
0
		/// <summary>
		/// The constructor is private: external callers should use the Create method.
		/// </summary>
		NetworkSessionComponent (ScreenManager screenManager, 
				NetworkSession networkSession)
		: base(screenManager.Game)
			{
			this.screenManager = screenManager;
			this.networkSession = networkSession;

			// Hook up our session event handlers.
			networkSession.GamerJoined += GamerJoined;
			networkSession.GamerLeft += GamerLeft;
			networkSession.SessionEnded += NetworkSessionEnded;
		}
コード例 #30
0
		/// <summary>
		/// Creates a new NetworkSessionComponent.
		/// </summary>
		public static void Create (ScreenManager screenManager,
				NetworkSession networkSession)
		{
			Game game = screenManager.Game;

			// Register this network session as a service.
			game.Services.AddService (typeof(NetworkSession), networkSession);

			// Create a NetworkSessionComponent, and add it to the Game.
			game.Components.Add (new NetworkSessionComponent (screenManager,
							networkSession));
		}
コード例 #31
0
 /// <summary>
 /// Event handler for when the Options menu entry is selected.
 /// </summary>
 void OptionsMenuEntrySelected(object sender, EventArgs e)
 {
     ScreenManager.AddScreen(new OptionsMenuScreen());
 }
コード例 #32
0
        /// <summary>
        /// Draws the pause menu screen. This darkens down the gameplay screen
        /// that is underneath us, and then chains to the base MenuScreen.Draw.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            base.Draw(gameTime);
        }
コード例 #33
0
 /// <summary>
 /// Event handler for when the Options menu entry is selected.
 /// </summary>
 void LyircMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
 }
コード例 #34
0
        /// <summary>
        /// Lets the game respond to player input. Unlike the Update method,
        /// this will only be called when the gameplay screen is active.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Check if the user's input is null and throw an exception if it is
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            // Look up inputs for the active player profile
            KeyboardState keyboardState = input.CurrentKeyboardStates;

            // Checks to see if the user hit the pause button (esc)
            if (input.IsPauseGame())
            {
                // Add a new screen on top of our current screen to display the pause menu
                ScreenManager.AddScreen(new PauseMenuScreen());
            }

            // Check to see if our menu selection key was hit (Z)
            if (input.IsMenuSelect())
            {
                // Check to see if the player already has the move they are on in the selection screen equipped
                if (PlayerInfo.Moves.Contains(selectedMove))
                {
                    // Get the index of this move and remove it from the player's currently equipped moves
                    int index = Array.IndexOf(PlayerInfo.Moves, selectedMove);
                    PlayerInfo.Moves[index] = -1;
                }
                // Otherwise, if there is an open slot for equipping a new move
                else if (PlayerInfo.Moves.Contains(-1))
                {
                    // Get the index of the open slot and fill it with the new selected index
                    int index = Array.IndexOf(PlayerInfo.Moves, -1);
                    PlayerInfo.Moves[index] = selectedMove;
                }
            }
            // Check to see if the start button (enter) was pressed and if the player has any moves equipped (I.E anything with an index greater than -1)
            if (input.IsStartButton() && Array.Exists(PlayerInfo.Moves, selectedMove => selectedMove > -1))
            {
                // Load the next match
                LoadingScreen.Load(ScreenManager, false, new MatchupInfoScreen());
            }
            // Check to see if the up arrow key was hit
            if (input.IsMenuUp())
            {
                // Decrement the selected move
                selectedMove--;

                // Wrap the selected move around if the user goes beyond the minimum moves
                if (selectedMove < 0)
                {
                    selectedMove = maxMoves - 1;
                }
            }
            // Check to see if the down arrow key was hit
            if (input.IsMenuDown())
            {
                // Increment the selected move
                selectedMove++;

                // Wrap back around if the player goes beyond the maximum amount of moves
                if (selectedMove >= maxMoves)
                {
                    selectedMove = 0;
                }
            }
        }