public void ButtonClicked(MouseState mouseState, MouseState oldMouseState, GraphicsDeviceManager graphics, ContentManager content)
        {
            if (mouseState.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed)
            {
                if (pos.Contains(new Point(mouseState.X, mouseState.Y)))
                {
                    //Start
                    if (buttonName == "start" && Menu.fadeOut == false)
                    {
                        Menu.stateName = "play";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                    }
                    else if (buttonName == "options" && Menu.fadeOut == false)
                    {
                        Menu.stateName = "options";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                    }
                    else if (buttonName == "quit")
                    {
                        willQuit = true;
                    }
                    //Options
                    else if (buttonName == "back")
                    {
                        Menu.stateName = "main";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                    }
                    else if (buttonName == "muteMusic")
                    {
                        if (MediaPlayer.IsMuted == true)
                        {
                            Menu.buttons[1].tex = SpriteSheetManager.muteMusicOff.texture;
                            MediaPlayer.IsMuted = false;
                        }
                        else if (MediaPlayer.IsMuted == false)
                        {
                            Menu.buttons[1].tex = SpriteSheetManager.muteMusicOn.texture;
                            MediaPlayer.IsMuted = true;
                        }
                    }
                    else if (buttonName == "fullScreen")
                    {
                        if (isFullScreen == true)
                        {
                            Menu.buttons[2].tex = SpriteSheetManager.fullScreenOff.texture;
                            isFullScreen        = false;
                        }
                        else if (isFullScreen == false)
                        {
                            Menu.buttons[2].tex = SpriteSheetManager.fullScreenOn.texture;
                            isFullScreen        = true;
                        }
                    }
                    //Play
                    else if (buttonName == "newGame")
                    {
                        SavefileHandler.DeleteSavefile();

                        Game1.gameState = Game1.GameState.Play;

                        for (int i = 0; i < Menu.buttons.Count;)
                        {
                            Menu.buttons.Remove(Menu.buttons[0]);
                        }
                    }
                    //Continue on saved file
                    else if (buttonName == "continue")
                    {
                        if (Game1.saveFileExist)
                        {
                            Level.LoadFromSave();
                            Game1.gameState = Game1.GameState.Play;
                            Menu.LoadButtons();
                        }
                    }
                    else if (buttonName == "resume")
                    {
                        Game1.gameState = Game1.GameState.Play;
                    }
                    else if (buttonName == "pauseOptions")
                    {
                        Menu.stateName = "pauseOptions";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                    }
                    else if (buttonName == "pauseBack")
                    {
                        Menu.stateName = "pauseMain";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                    }
                    else if (buttonName == "pauseQuit")
                    {
                        Menu.stateName = "main";
                        if (Menu.f == 255)
                        {
                            Menu.fadeOut = true;
                            Menu.fadeIn  = false;
                        }
                        try
                        {
                            SavefileHandler.ReadFile("savefile.txt");
                            Game1.saveFileExist = true;
                        }
                        catch
                        {
                            Game1.saveFileExist = false;
                        }
                        Level.Load_Level(graphics, content);
                        Game1.gameState = Game1.GameState.Start;
                    }
                    else if (buttonName == "exitGame")
                    {
                        Level.enemyList.Clear();
                        Game1.gameState = Game1.GameState.Start;
                        Menu.menuState  = Menu.MenuState.MainMenuHome;
                        Menu.LoadButtons();
                        Menu.swap = SpriteSheetManager.backGroundTex.texture;
                        Level.Load_Level(graphics, content);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Sets the gamestate to Game Over
 /// </summary>
 public static void SetGameOverScreen()
 {
     GameOver.LoadScreen();
     gameState = GameState.GameOver;
     SavefileHandler.DeleteSavefile();
 }