Esempio n. 1
0
        protected override void LoadContent()
        {
            gameState   = GameState.Start;
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Constants.LoadConstants();
            graphics.PreferredBackBufferWidth  = Constants.windowWidth;
            graphics.PreferredBackBufferHeight = Constants.windowHeight;
            graphics.ApplyChanges();

            //kub = Content.Load<Texture2D>(@"kub");

            SpriteSheetManager.LoadContent(Content);
            SoundManager.LoadAudio(Content);
            LoadWeaponsAndItems.LoadAllWeaponsAndItems();
            EnemyManager.LoadEnemies();
            HUD.Load(Content);
            Menu.Load(Content);
            try
            {
                SavefileHandler.ReadFile("savefile.txt");
                saveFileExist = true;
            }
            catch
            {
                saveFileExist = false;
            }
            Menu.LoadButtons();

            camera = new Camera(GraphicsDevice.Viewport);
            Level.Load_Level(graphics, Content);

            MediaPlayer.IsRepeating = true;
        }
Esempio n. 2
0
 /// <summary>
 /// Loads information about the state of the level from a savefile.
 /// </summary>
 public static void LoadFromSave()
 {
     SavefileHandler.LoadFromFile();
     loadBoss = false;
     LoadBossRoom();
     loadBoss = true;
     HUD.UpdateCurrencyHUD(currency);
 }
        /// <summary>
        /// Saves the player stats to the savefile
        /// </summary>
        public void SetSaveFile()
        {
            Weapon weaponToSave;

            if (equippedMelee != null)
            {
                weaponToSave = equippedMelee;
            }
            else
            {
                weaponToSave = equippedRange;
            }
            SavefileHandler.SaveToFile(weaponToSave, health, maxHealth, attackSpeedMultiplier, damageMultiplier, speedMultiplier);
        }
        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);
                    }
                }
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Sets the gamestate to Game Over
 /// </summary>
 public static void SetGameOverScreen()
 {
     GameOver.LoadScreen();
     gameState = GameState.GameOver;
     SavefileHandler.DeleteSavefile();
 }