public Launcher() { GameSaverAndLoader.loadMeta(0); InitializeComponent(); setUpBasedOnSaveSlot(0); game = new Game1(); content = new ContentManager(Game1.instance.Content.ServiceProvider, Game1.instance.Content.RootDirectory); testSoundAmbient = content.Load <SoundEffect>("Sounds/Ambiance/none-1"); soundAmbientInstance = testSoundAmbient.CreateInstance(); soundAmbientInstance.IsLooped = true; testSoundMonster = content.Load <SoundEffect>("Sounds/Wav/Gun_0"); soundMonsterInstance = testSoundMonster.CreateInstance(); soundMonsterInstance.IsLooped = true; testSoundMusic = content.Load <SoundEffect>("Sounds/Music/song1_journey_0"); soundMusicInstance = testSoundMusic.CreateInstance(); soundMusicInstance.IsLooped = true; toolTip.SetToolTip(start_game_button, "Start the game with the current settings."); toolTip.SetToolTip(trackbar_sound_monster, "Sets the volume for the player, monsters, UI, etc."); toolTip.SetToolTip(trackbar_sound_ambient, "Sets the volume for the background noise."); toolTip.SetToolTip(trackbar_sound_music, "Sets the volume for the music."); toolTip.SetToolTip(button_audio_test, "Starts or stops audio so that you can adjust volume levels by ear."); toolTip.SetToolTip(difficulty_hard, "Turns off adaptive difficulty. The game will no longer get harder as you get better."); toolTip.SetToolTip(difficulty_very_hard, "Turns on adaptive difficulty. The game will will try to match its difficulty to your skill level."); playing_audio = false; this.saveSlot.SelectedIndex = 0; }
public override void acceptInput(GameTime time, KeyboardState currentKeyboardState, MouseState currentMouseState, KeyboardState prevKeyboardState, MouseState prevMouseState) { if (currentMouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released) { if (saveAndExitRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); ready = true; GameSaverAndLoader.save(Game1.selectedSaveSlot, world); Game1.instance.Exit(); } else if (continueRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); keepGoing(); } else if (optionsMenuRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); keepGoing(); Game1.instance.queuedSplashScreens.Add(new SettingsScreen(0, world)); } else if (suicideRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); ready = true; Game1.instance.queuedSplashScreens.Add(new SuicideScreen(0, world)); } } if (currentKeyboardState.IsKeyDown(Keys.Escape) && prevKeyboardState.IsKeyUp(Keys.Escape)) { keepGoing(); } }
public void keepGoing() { if (world is TutorialWorld) { ((TutorialWorld)world).processInstructionStrings(); } SoundManager.resume(); world.decorator.ambientSoundManager.resume(); ready = true; GameSaverAndLoader.saveKeyBinds(Game1.selectedSaveSlot); }
/** * * unlocks the character at a given character index. Returns true if the character was unlocked, * returns false if the character was already unlocked. * */ public static bool unlockCharacter(int characterIndex) { bool alreadyUnlocked = MetaData.unlocks.Contains(characterIndex); if (!alreadyUnlocked) { MetaData.unlocks.Add(characterIndex); GameSaverAndLoader.saveMeta(Game1.selectedSaveSlot); } return(!alreadyUnlocked); }
public MainMenu() { int screenW = Game1.instance.graphics.PreferredBackBufferWidth; int screenH = Game1.instance.graphics.PreferredBackBufferHeight; int screenWidthOverFour = Game1.instance.graphics.PreferredBackBufferWidth / 4; int screenHeightOverTwo = Game1.instance.graphics.PreferredBackBufferHeight / 2; tutorialRect = new Rectangle(screenWidthOverFour - 50, screenHeightOverTwo, 75, 40); newGameRect = new Rectangle(screenWidthOverFour * 2 - 50, screenHeightOverTwo, 112, 40); continueRect = new Rectangle(screenWidthOverFour * 3 - 50, screenHeightOverTwo, 85, 40); allowResume = GameSaverAndLoader.doesSaveExist(Game1.selectedSaveSlot); exitRect = new Rectangle(screenW - 30 - 10, 10, 30, 30); }
public override void acceptInput(GameTime time, KeyboardState currentKeyboardState, MouseState currentMouseState, KeyboardState prevKeyboardState, MouseState prevMouseState) { this.currentMouseState = currentMouseState; if (currentMouseState.LeftButton.Equals(ButtonState.Pressed) && prevMouseState.LeftButton.Equals(ButtonState.Released)) { if (tutorialRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); Game1.instance.world = null; World.universeProperties = new UniverseProperties("" + new Random(System.DateTime.Now.Millisecond).NextDouble() + "" + new Random(System.DateTime.Now.Minute).NextDouble() + "" + new Random((int)System.DateTime.Now.Ticks).NextDouble() + "" + new Random().NextDouble()); WorldBase world = new TutorialWorld(); Game1.instance.queuedSplashScreens.Add(new PlayerSelectScreen(MetaData.unlocks.ToArray(), world)); Card.setUpCards(); readyToContinue = true; Game1.isInTutorial = true; } if (newGameRect.Contains(currentMouseState.Position)) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); Game1.instance.world = null; World.universeProperties = new UniverseProperties("" + new Random(System.DateTime.Now.Millisecond).NextDouble() + "" + new Random(System.DateTime.Now.Minute).NextDouble() + "" + new Random((int)System.DateTime.Now.Ticks).NextDouble() + "" + new Random().NextDouble()); WorldBase world = Game1.instance.getWorldBasedOnDifficulty(0); Game1.instance.queuedSplashScreens.Add(new PlayerSelectScreen(MetaData.unlocks.ToArray(), world)); Card.setUpCards(); handleBottleAdditions(); Game1.instance.world = null; readyToContinue = true; Game1.isInTutorial = false; } if (continueRect.Contains(currentMouseState.Position) && allowResume) { SoundManager.getSound("click").playWithVariance(0, .25f, 0, SoundType.MONSTER); GameSaverAndLoader.load(Game1.selectedSaveSlot); handleBottleAdditions(); readyToContinue = true; Game1.isInTutorial = false; } if (exitRect.Contains(currentMouseState.Position)) { Game1.instance.Exit(); } } }
public override void acceptInput(GameTime time, KeyboardState currentKeyboardState, MouseState currentMouseState, KeyboardState prevKeyboardState, MouseState prevMouseState) { this.currentMouseState = currentMouseState; if (currentMouseState.LeftButton.Equals(ButtonState.Pressed) && prevMouseState.LeftButton.Equals(ButtonState.Released)) { foreach (PlayerStarterKit kit in PlayerKitRegistry.registry.Values) { if (kit.buttonRect.Contains(currentMouseState.Position) && !kit.locked) { if (GameSaverAndLoader.doesSaveExist(Game1.selectedSaveSlot)) { GameSaverAndLoader.deleteSave(Game1.selectedSaveSlot); } if (kit.id == 0 && !(world is TutorialWorld)) { /*Dictionary<Rectangle, string> images = new Dictionary<Rectangle, string>(); * * List<String> challengeImages = UniverseProperties.challangeListToStringList(); * * int imageWidth = 1000; * int imageHeight = 400; * for (int i = 0; i < 6; i++) * { * images.Add(new Rectangle(imageWidth * i, Game1.instance.graphics.PreferredBackBufferHeight / 2 - imageHeight / 2, imageWidth, imageHeight), "StorySplashes/story_" + i); * } * * Game1.instance.queuedSplashScreens.Add(new ScrollingSplashScreen(images, new List<string>()));*/ StartingCutscene startingCutscene = new StartingCutscene(world); kit.selectKit(startingCutscene); Game1.instance.switchWorlds(startingCutscene); } else { kit.selectKit(world); Game1.instance.switchWorlds(world); } readyToContinue = true; break; } } } }
public void setUpBasedOnSaveSlot(int slot) { Console.WriteLine("slot " + slot); GameSaverAndLoader.loadMeta(Game1.selectedSaveSlot); this.screenWBox.Text = MetaData.screenW + ""; this.screenHBox.Text = MetaData.screenH + ""; this.fullscreenOptionsBox.SelectedIndex = MetaData.screenSetting; this.trackbar_sound_ambient.Value = (int)(MetaData.audioSettingAmbient * 100); this.trackbar_sound_monster.Value = (int)(MetaData.audioSettingMonster * 100); this.trackbar_sound_music.Value = (int)(MetaData.audioSettingMusic * 100); if (MetaData.adaptiveDifficulty == 1) { difficulty_very_hard.Checked = true; } else { difficulty_hard.Checked = true; } }
private bool validateAndSave(int slot) { bool canSave = true; int w = 0; int h = 0; int fs = this.fullscreenOptionsBox.SelectedIndex; string displayError = ""; try { w = int.Parse(this.screenWBox.Text); if (w < 0 || w > 1920) { throw new FormatException(); } } catch (FormatException ex) { Logger.log("Exception when parsing width: " + ex.ToString()); canSave = false; displayError += "\nInvalid selection for screen width."; } try { h = int.Parse(this.screenHBox.Text); if (h < 0 || h > 1080) { throw new FormatException(); } } catch (FormatException ex) { Logger.log("Exception when parsing height: " + ex.ToString()); canSave = false; displayError += "\nInvalid selection for screen height."; } if (difficulty_very_hard.Checked) { MetaData.adaptiveDifficulty = 1; } else { MetaData.adaptiveDifficulty = 0; } if (canSave) { MetaData.screenW = w; MetaData.screenH = h; MetaData.screenSetting = fs; GameSaverAndLoader.saveMeta(slot); } else { MessageBoxButtons buttons = MessageBoxButtons.OK; MessageBox.Show("You put something dumb in one of the option boxes. Try something else?" + displayError, "Invalid launch parameters", buttons); } return(canSave); }