public override void LoadContent() { splashScreen = Content.Load <Texture2D>("Textures/SplashScreenTex"); splash = new Sprite3(true, splashScreen, 0, 0); colorSplash = new Color(255, 211, 228); data = SaveGameManager.LoadGameState("savegame.xml"); Resources.currPlayLevel = data.currLevel; Resources.score = data.currScore; Resources.volume = data.currVolume; MediaPlayer.Volume = Resources.volume; Resources.graphicsQuality = data.currGraphics; Game1.particleManager.setMaxParticleAmount(1500); int x = data.currLives; if (Game1.spriteManager.player != null) { Game1.spriteManager.player.sprite.hitPoints = x; } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); // Setup basics Resources.LoadContent(Content); SoundManager.LoadContent(Content); LineBatch.init(GraphicsDevice); HighScoreManager.Initialize(); SaveGameManager.Initialize(); // Setup our media palyer MediaPlayer.IsRepeating = true; MediaPlayer.Play(SoundManager.getSong()); MediaPlayer.Volume = Resources.volume; levelManager = new RC_GameStateManager(); // Add our player that we will keep throughout the entire run of this game Game1.spriteManager.addSpriteActor(new Player(Resources.Player, Game1.screenSize / 2, Vector2.Zero)); // heaps of levels is most likely in-efficient use of state management, better to combine large amounts of these levels // and then have minor nested state management, e.g. combining levels 1-4 and menu/options, etc. However, due to the scale // of this game and time limits, I believe the below code suffices. levelManager.AddLevel(0, new LevelOne()); levelManager.getLevel(0).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(1, new LevelTwo()); levelManager.getLevel(1).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(2, new LevelThree()); levelManager.getLevel(2).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(3, new LevelSplash()); levelManager.getLevel(3).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(4, new LevelMenu()); levelManager.getLevel(4).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(5, new LevelOptions()); levelManager.getLevel(5).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(6, new LevelLoad()); levelManager.getLevel(6).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); // Preferrable to load in pause content now levelManager.AddLevel(7, new LevelPause()); levelManager.getLevel(7).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.getLevel(7).LoadContent(); // Preferrable to load in how to play content now (works on push/pop stack same as pause) levelManager.AddLevel(8, new LevelHowToPlay()); levelManager.getLevel(8).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.getLevel(8).LoadContent(); levelManager.AddLevel(9, new LevelGameOver()); levelManager.getLevel(9).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(10, new LevelFour()); levelManager.getLevel(10).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(11, new LevelFiveBoss()); levelManager.getLevel(11).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(12, new LevelWin()); levelManager.getLevel(12).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.AddLevel(13, new LevelHighScores()); levelManager.getLevel(13).InitializeLevel(GraphicsDevice, spriteBatch, Content, levelManager); levelManager.setLevel(3); }
/// <summary> /// Save game on exit /// </summary> /// <param name="sender"></param> /// <param name="args"></param> protected override void OnExiting(object sender, EventArgs args) { SaveGameManager.SaveGame(); base.OnExiting(sender, args); }