public void UpdateMenu() { var keyboardState = KeyboardExtended.GetState(); if (keyboardState.WasKeyJustUp(Keys.Up)) { loadScreen.menuIndex--; } else if (keyboardState.WasKeyJustUp(Keys.Down)) { loadScreen.menuIndex++; } if (keyboardState.WasKeyJustUp(Keys.Enter)) { switch (levelNumber) { case "StartScreen": levelNumber = "Load"; loadScreen.menuIndex = 1; sceneCreator.UnloadObjects(true, _objects); sceneCreator.LevelLoader(Content, graphics.GraphicsDevice, _objects, levelNumber, checkPoint, false); break; case "Load": loadMenu.ChooseSaveFIle(_objects, sceneCreator, Content, GraphicsDevice, loadScreen); break; case "GameOver": levelNumber = previousLevel; sceneCreator.UnloadObjects(true, _objects); inMenu = false; sceneCreator.LevelLoader(Content, graphics.GraphicsDevice, _objects, levelNumber, checkPoint, true); break; default: inMenu = false; PauseMenu.active = false; break; } if (keyboardState.IsKeyDown(Keys.RightShift) && keyboardState.IsKeyDown(Keys.V) && keyboardState.IsKeyDown(Keys.Space)) { levelNumber = "StartScreen"; checkPoint = "1"; inMenu = true; Entity.applyGravity = true; sceneCreator.UnloadObjects(true, _objects); sceneCreator.LevelLoader(Content, graphics.GraphicsDevice, _objects, levelNumber, checkPoint, false); } } }
public void ChooseSaveFIle(List <GameObject> _objects, SceneCreator sceneCreator, ContentManager content, GraphicsDevice graphics, LoadScreen loadScreen) { if (loadScreen.menuIndex != 4) { Game1.saveSlot = loadScreen.menuIndex; if (loadScreen.deleteMode) { XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", emptyList); XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", 3); loadScreen.menuIndex = 1; loadScreen.deleteMode = false; //Console.WriteLine("file deleted"); } else { Game1.inMenu = false; Game1.levelNumber = "0"; Game1._destroyedPermanent = XmlSerialization.ReadFromXmlFile <List <string> >("SaveFile0" + Game1.saveSlot + ".txt"); HUD.playerMaxHealth = XmlSerialization.ReadFromXmlFile <int>("HealthFile0" + Game1.saveSlot + ".txt"); sceneCreator.UnloadObjects(true, _objects); sceneCreator.LevelLoader(content, graphics, _objects, Game1.levelNumber, Game1.checkPoint, true); } } else { if (loadScreen.deleteMode) { loadScreen.deleteMode = false; } else { loadScreen.deleteMode = true; loadScreen.menuIndex = 1; } } }
//IS PLAYER DEAD? public void CheckForDeath(List <GameObject> _objects, SceneCreator sceneCreator, GraphicsDeviceManager graphics, ContentManager content, string roomNumber) { if (playerDead) { if (SceneCreator.soundEffectInstance != null) { SceneCreator.soundEffectInstance.Stop(true); SceneCreator.soundEffectInstance.Dispose(); } deathTimer--; if (deathTimer <= 0) { HUD.playerHealth = HUD.playerMaxHealth; _objects[0].invincible = false; sceneCreator.UnloadObjects(true, _objects); if (HUD.playerLives > 0) { HUD.playerLives--; Game1.inMenu = false; sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, roomNumber, true); Camera.LookAt(_objects[0].position); } if (HUD.playerLives == 0) { HUD.playerLives = 3; Game1.levelNumber = "GameOver"; Game1.checkPoint = roomNumber = "1"; Game1.inMenu = true; HUD.rupeeCount = 0; //clear respawn list foreach (var obj in Game1._destroyedObjects) { clearList.Add(obj); } foreach (string o in clearList) { Game1._destroyedObjects.Remove(o); } sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, roomNumber, true); XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", Game1._destroyedPermanent); XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", HUD.playerMaxHealth); } PauseMenu.active = false; deathTimer = deathTimerMax; playerDead = false; } } }
public void ScreenTransition(List <GameObject> _objects, GraphicsDeviceManager graphics, ContentManager content, SceneCreator sceneCreator, string direction, string roomNumber) { //sliding screens if (roomPlaceHolder != "Overworld" && Game1.levelNumber != "Overworld" && !fading) { if (direction == "right") { Camera.cameraMin.X = Camera.position.X; _objects[0].position.Y = _objects[0].position.Y; _objects[0].position.X += 0.5f; Camera.cameraMin.X += 8; Camera.cameraMax.X += 8; } if (direction == "left") { Camera.cameraMax.X = Camera.position.X; _objects[0].position.Y = _objects[0].position.Y; _objects[0].position.X -= 0.5f; Camera.cameraMin.X -= 8; Camera.cameraMax.X -= 8; } screenTimer--; if (screenTimer < 0) { sceneCreator.UnloadObjects(false, _objects); roomNumber = roomPlaceHolder; Game1.checkPoint = roomNumber; Door.doorEnter = false; screenTimer = 50; sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, roomNumber, false); Entity.applyGravity = true; } } if ((roomPlaceHolder == "Overworld" || Game1.levelNumber == "Overworld") || fading) { FadeInOut(); if (fadeComplete && screenTimer <= 0 && roomPlaceHolder == "Overworld") { sceneCreator.UnloadObjects(true, _objects); Game1.levelNumber = roomPlaceHolder; Entity.applyGravity = false; sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, "1", true); } else if (fadeComplete && screenTimer <= 0 && Game1.levelNumber == "Overworld") { sceneCreator.UnloadObjects(true, _objects); Game1.levelNumber = roomPlaceHolder; Entity.applyGravity = true; sceneCreator.LevelLoader(content, graphics.GraphicsDevice, _objects, Game1.levelNumber, "1", true); } if (fadeComplete) { fadeComplete = false; fadeOut = true; screenTimer = 50; // save the game XmlSerialization.WriteToXmlFile("SaveFile0" + Game1.saveSlot + ".txt", Game1._destroyedPermanent); XmlSerialization.WriteToXmlFile("HealthFile0" + Game1.saveSlot + ".txt", HUD.playerMaxHealth); } } }