Exemple #1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            gameState       = GameState.StartMenu;
            LoadedGameState = GameState.StartMenu;

            startMenu = new StartMenuScreen(graphics);
            startMenu.Initialize();

            //optionsMenuScreen = new OptionsMenuScreen();
            //optionsMenuScreen.Initialize();

            //gameScreen = new GameScreen(graphics);
            // Move all code which requires Content to LoadContent
            //gameScreen.Initialize(Content, GraphicsDevice);
            base.Initialize();
        }
Exemple #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            gameState = GameState.StartMenu;
            LoadedGameState = GameState.StartMenu;

            startMenu = new StartMenuScreen(graphics);
            startMenu.Initialize();

            //optionsMenuScreen = new OptionsMenuScreen();
            //optionsMenuScreen.Initialize();

            //gameScreen = new GameScreen(graphics);
            // Move all code which requires Content to LoadContent
            //gameScreen.Initialize(Content, GraphicsDevice);
            base.Initialize();
        }
Exemple #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                gameState = GameState.StartMenu;

            // TODO: Add your update logic here
            if (gameState == GameState.StartMenu)
            {
                if (LoadedGameState != GameState.StartMenu)
                {
                    Content.Unload();
                    startMenu = new StartMenuScreen(graphics);
                    startMenu.Initialize();
                    startMenu.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.StartMenu;
                }
                startMenu.Update(gameTime);
            }

            if (gameState == GameState.OptionsMenu)
            {
                if (LoadedGameState != GameState.OptionsMenu)
                {
                    Content.Unload();
                    optionsMenuScreen = new OptionsMenuScreen();
                    optionsMenuScreen.Initialize();
                    optionsMenuScreen.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.OptionsMenu;
                }
                optionsMenuScreen.Update(gameTime);
            }

            if (gameState == GameState.Playing)
            {
                if (LoadedGameState != GameState.Playing)
                {
                    Content.Unload();
                    gameScreen = new GameScreen(graphics);
                    gameScreen.Initialize(Content, GraphicsDevice);
                    gameScreen.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.Playing;
                }
                gameScreen.Update(gameTime, GraphicsDevice);
            }

            // Gameover goes to Start Menu for now
            if (gameState == GameState.GameOver)
            {
                gameState = GameState.StartMenu;
                if (LoadedGameState != GameState.StartMenu)
                {
                    Content.Unload();
                    startMenu = new StartMenuScreen(graphics);
                    startMenu.Initialize();
                    startMenu.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.StartMenu;
                }
                startMenu.Update(gameTime);
            }

            if (gameState == GameState.Exiting)
                this.Exit();

            base.Update(gameTime);
        }
Exemple #4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                gameState = GameState.StartMenu;
            }

            // TODO: Add your update logic here
            if (gameState == GameState.StartMenu)
            {
                if (LoadedGameState != GameState.StartMenu)
                {
                    Content.Unload();
                    startMenu = new StartMenuScreen(graphics);
                    startMenu.Initialize();
                    startMenu.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.StartMenu;
                }
                startMenu.Update(gameTime);
            }

            if (gameState == GameState.OptionsMenu)
            {
                if (LoadedGameState != GameState.OptionsMenu)
                {
                    Content.Unload();
                    optionsMenuScreen = new OptionsMenuScreen();
                    optionsMenuScreen.Initialize();
                    optionsMenuScreen.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.OptionsMenu;
                }
                optionsMenuScreen.Update(gameTime);
            }

            if (gameState == GameState.Playing)
            {
                if (LoadedGameState != GameState.Playing)
                {
                    Content.Unload();
                    gameScreen = new GameScreen(graphics);
                    gameScreen.Initialize(Content, GraphicsDevice);
                    gameScreen.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.Playing;
                }
                gameScreen.Update(gameTime, GraphicsDevice);
            }

            // Gameover goes to Start Menu for now
            if (gameState == GameState.GameOver)
            {
                gameState = GameState.StartMenu;
                if (LoadedGameState != GameState.StartMenu)
                {
                    Content.Unload();
                    startMenu = new StartMenuScreen(graphics);
                    startMenu.Initialize();
                    startMenu.LoadContent(Content, GraphicsDevice);
                    LoadedGameState = GameState.StartMenu;
                }
                startMenu.Update(gameTime);
            }

            if (gameState == GameState.Exiting)
            {
                this.Exit();
            }

            base.Update(gameTime);
        }