示例#1
0
        // Pass the previous and current keyboard and gamepad states to the ProcessInput method of the currently active menu
        private void MenuInput()
        {
            if (!menusRunning)
            {
                return;
            }

            MenuWindow newActive = activeMenu.ProcessInput(prevKeyState, nextKeyState);

            if (newActive == quitGame)
            {
                this.Exit();
            }
            else if (newActive == startGame)
            {
                menusRunning = false;
                LoadLevel();
            }
            else if (newActive == null)
            {
                this.Exit();
            }
            else if (newActive != activeMenu)
            {
                newActive.WakeUp();
            }

            activeMenu = newActive;
        }
示例#2
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            orbitTexture          = Content.Load <Texture2D>("Deco/dash");
            explosion             = Content.Load <Texture2D>("seq");
            TextureBackgroundMenu = Content.Load <Texture2D>("TextureBackgroundMenu");
            MainMenu      = Content.Load <Texture2D>("MainMenu");
            Help          = Content.Load <Texture2D>("Help");
            Credits       = Content.Load <Texture2D>("Credits");
            Verdana40     = Content.Load <SpriteFont>("Verdana40");
            CloisterBlack = Content.Load <SpriteFont>("CloisterBlack");

            Audio.LoadAudio(Content, "Content/Audio/game.audio");

            // Create menus and add them to the menuList
            menuMain    = new MenuWindow("The Gods Must Be Crazy", MainMenu, CloisterBlack, Verdana40);
            menuCredits = new MenuWindow("Credits", Credits, CloisterBlack, Verdana40);
            menuHelp    = new MenuWindow("How To Play", Help, CloisterBlack, Verdana40);

            startGame = new MenuWindow(null, null, null, null);
            quitGame  = new MenuWindow(null, null, null, null);

            // Add all the menus to our menu list
            menuList.Add(menuMain);
            menuList.Add(menuCredits);
            menuList.Add(menuHelp);
            // Give each of the menus its options
            menuMain.AddMenuItem("New Game", startGame);
            menuMain.AddMenuItem("How To Play", menuHelp);
            menuMain.AddMenuItem("Credits", menuCredits);
            menuMain.AddMenuItem("Quit Game", quitGame);

            menuHelp.AddMenuItem("", menuMain);
            menuCredits.AddMenuItem("", menuMain);

            menuMain.WakeUp();

            activeMenu = menuMain;
        }