示例#1
0
        private void MenuInput(KeyboardState currentKeybState, GamePadState currentGamePadState)
        {
            MenuWindow newActive = activeMenu.ProcessInput(lastKeybState, currentKeybState, lastGamePadState, currentGamePadState);

            if (newActive == startGameEasy)
            {
                //set level to easy
                menusRunning = false;
            }
            else if (newActive == startGameNormal)
            {
                //set level to normal
                menusRunning = false;
            }
            else if (newActive == startGameHard)
            {
                //set level to hard
                menusRunning = false;
            }
            else if (newActive == null)
            {
                this.Exit();
            }
            else if (newActive != activeMenu)
            {
                newActive.WakeUp();
            }

            activeMenu = newActive;
        }
示例#2
0
        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            SpriteFont menuFont        = Content.Load <SpriteFont>("ourfont");
            Texture2D  backgroundImage = Content.Load <Texture2D>("bg");
            Texture2D  bg = Content.Load <Texture2D>("bg2");

            spriteBatch = new SpriteBatch(device);

            Effect ppEffect = Content.Load <Effect>("postprocessing");

            postProcessor = new PostProcessor(device, ppEffect);

            //dummy menus
            startGameEasy   = new MenuWindow(null, null, null);
            startGameNormal = new MenuWindow(null, null, null);
            startGameHard   = new MenuWindow(null, null, null);

            MenuWindow menuMain    = new MenuWindow(menuFont, "Main Menu", backgroundImage);
            MenuWindow menuNewGame = new MenuWindow(menuFont, "Start a New Game", bg);
            MenuWindow menuOptions = new MenuWindow(menuFont, "Options Menu", backgroundImage);

            menuList.Add(menuMain);
            menuList.Add(menuNewGame);
            menuList.Add(menuOptions);

            menuMain.AddMenuItem("New Game", menuNewGame);
            menuMain.AddMenuItem("Load Game", menuMain);
            menuMain.AddMenuItem("Options", menuOptions);
            menuMain.AddMenuItem("Exit Game", null);

            menuNewGame.AddMenuItem("Easy", startGameEasy);
            menuNewGame.AddMenuItem("Normal", startGameNormal);
            menuNewGame.AddMenuItem("Hard", startGameHard);
            menuNewGame.AddMenuItem("Back to Main menu", menuMain);

            menuOptions.AddMenuItem("Change controls", menuMain);
            menuOptions.AddMenuItem("Change graphics setting", menuMain);
            menuOptions.AddMenuItem("Change sound setting", menuMain);
            menuOptions.AddMenuItem("Back to Main menu", menuMain);

            activeMenu = menuMain;
            menuMain.WakeUp();
        }