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
            mainMenuWindow    = new MainMenu(Content);
            threeElementsMode = new FirstMode(Content);
            fiveElementsMode  = new SecondMode(Content);
            aboutWindow       = new AboutWindow(Content);

            base.Initialize();
        }
Exemple #2
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 ||
                (gameStage == GameState.EXIT_GAME))
            {
                this.Exit();
            }

            MouseState    mouse    = Mouse.GetState();
            KeyboardState keyboard = Keyboard.GetState();

            //Exit to Main Menu
            if (keyboard.IsKeyDown(Keys.Escape))
            {
                gameStage = GameState.MAIN_MENU;
            }

            //Management of all the game states
            if (gameStage == GameState.MAIN_MENU)
            {
                //resolve the issue with music playing and new games
                if (!this.isReloaded) //to make it only once, not every game tick
                {
                    threeElementsMode.Update(gameTime, Content, mouse);
                    fiveElementsMode.Update(gameTime, Content, mouse);
                    threeElementsMode = new FirstMode(Content);
                    fiveElementsMode  = new SecondMode(Content);
                    this.isReloaded   = true;
                }

                //begin updating the main menu window
                mainMenuWindow.Update(mouse);
            }
            else if (gameStage == GameState.THREE_OBJECTS)
            {
                threeElementsMode.Update(gameTime, Content, mouse);
                this.isReloaded = false;
            }
            else if (gameStage == GameState.FIVE_OBJECTS)
            {
                fiveElementsMode.Update(gameTime, Content, mouse);
                this.isReloaded = false;
            }
            else if (gameStage == GameState.ABOUT_WINDOW)
            {
                aboutWindow.Update(mouse);
                this.isReloaded = false;
            }

            base.Update(gameTime);
        }