Example #1
0
        /* Button handler for the menus */
        public static void ProcessButtons()
        {
            View.mainMenu.MainToGame.OnClick = (Entity button) =>
            {
                ObjectManager.SetLevels(Content);
                gameState = GameState.playing;
            };

            View.mainMenu.MainToLoad.OnClick = (Entity button) =>
            {
                SaveNLoad loadGame = new SaveNLoad();
                loadGame.read();
                Pathfinder.CreateGrid(ObjectManager.currentLevel);
                ObjectManager.currentLevel.setPaths();
                gameState = GameState.playing;
            };

            View.mainMenu.MainToQuit.OnClick = (Entity button) => exit = true;

            View.gameOver.OverToMain.OnClick = (Entity button) => gameState = GameState.mainmenu;

            View.gameOver.OverToExit.OnClick = (Entity button) => exit = true;

            View.pauseMenu.PausetoGame.OnClick = (Entity button) => gameState = GameState.playing;

            View.pauseMenu.PausetoMain.OnClick = (Entity button) =>
            {
                SaveNLoad saveGame = new SaveNLoad();
                saveGame.save();
                gameState = GameState.mainmenu;
            };
            View.pauseMenu.PausetoQuit.OnClick = (Entity button) => exit = true;
        }
Example #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)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Controller.exit == true)
            {
                Exit();
            }

            ClearText(gameTime);

            Controller.Update(gameTime);


            // Poll for current keyboard state
            KeyboardState state = Keyboard.GetState();

            Player player = ObjectManager.currentLevel.Player;

            //update camera
            camera.follow(player);
            Input.CheckInputs();

            if (Input.isFullScreen != graphics.IsFullScreen)
            {
                graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }



            SaveNLoad saveI = new SaveNLoad();

            ObjectManager.Update(gameTime);


            base.Update(gameTime);
        }