diff --git a/.vs/EvilSatellites/v16/.suo b/.vs/EvilSatellites/v16/.suo index 1691341..8100790 100644 Binary files a/.vs/EvilSatellites/v16/.suo and b/.vs/EvilSatellites/v16/.suo differ diff --git a/EvilSatellites/Game1.cs b/EvilSatellites/Game1.cs index 84afca3..20198ba 100644 --- a/EvilSatellites/Game1.cs +++ b/EvilSatellites/Game1.cs @@ -36,8 +36,6 @@ namespace EvilSatellites protected override void Update(GameTime gameTime) { - if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) - Exit(); // TODO: Add your update logic here _manager.Update(gameTime); diff --git a/EvilSatellites/GameSettings.cs b/EvilSatellites/GameSettings.cs new file mode 100644 index 0000000..ccfc17a --- /dev/null +++ b/EvilSatellites/GameSettings.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EvilSatellites +{ + public static class GameSettings + { + public static bool PreferSAPI = true; + + } +} diff --git a/EvilSatellites/MusicManager.cs b/EvilSatellites/MusicManager.cs index f7d9bac..fb0eb73 100644 --- a/EvilSatellites/MusicManager.cs +++ b/EvilSatellites/MusicManager.cs @@ -9,6 +9,7 @@ namespace EvilSatellites { public class MusicManager { + public string CurrentFile; public ISoundEffect Song; public float _Volume; public float Volume { @@ -17,9 +18,9 @@ namespace EvilSatellites { if (IsPlaying) { - Song.Volume = Volume; + Song.Volume = value; } - _Volume = Volume; + _Volume = value; } } public bool IsPlaying; @@ -33,6 +34,7 @@ namespace EvilSatellites public void Play(string path) { + if (path == CurrentFile) return; if (IsPlaying) { Song.Stop(); @@ -43,6 +45,7 @@ namespace EvilSatellites Song.Play(); Song.Volume = _Volume; Song.Loop = true; + CurrentFile = path; IsPlaying = true; } diff --git a/EvilSatellites/Program.cs b/EvilSatellites/Program.cs index 04c9408..7edd58b 100644 --- a/EvilSatellites/Program.cs +++ b/EvilSatellites/Program.cs @@ -9,10 +9,12 @@ namespace EvilSatellites { DavyKager.Tolk.Load(); - DavyKager.Tolk.TrySAPI(true); - - DavyKager.Tolk.PreferSAPI(true); + if (GameSettings.PreferSAPI) + { + DavyKager.Tolk.TrySAPI(true); + DavyKager.Tolk.PreferSAPI(true); + } using (var game = new Game1()) game.Run(); } diff --git a/EvilSatellites/Screens/GameScreen.cs b/EvilSatellites/Screens/GameScreen.cs index 7ea475a..286251c 100644 --- a/EvilSatellites/Screens/GameScreen.cs +++ b/EvilSatellites/Screens/GameScreen.cs @@ -223,6 +223,18 @@ namespace EvilSatellites.Screens { DavyKager.Tolk.Output(Objects.Count.ToString()); } + if (Input.IsJustPressed(Keys.PageUp)) + { + Manager.Music.Volume = Manager.Music.Volume + 0.05f; + } + if (Input.IsJustPressed(Keys.PageDown)) + { + Manager.Music.Volume = Manager.Music.Volume - 0.05f; + } + if (Input.IsJustPressed(Keys.Escape)) + { + EndGame(); + } } private void CheckCollisions() diff --git a/EvilSatellites/Screens/MainMenuScreen.cs b/EvilSatellites/Screens/MainMenuScreen.cs index 0ca62d6..132f890 100644 --- a/EvilSatellites/Screens/MainMenuScreen.cs +++ b/EvilSatellites/Screens/MainMenuScreen.cs @@ -15,20 +15,29 @@ namespace EvilSatellites.Screens MenuOptions = new MenuContainer("Main Menu", "Navigate with up and down arrows,, and enter to select."); MenuOptions.Add(new MenuEntry("Start", "Start the game")) - .Add(new MenuEntry("Exit", "Exit the game")) - .Add(new MenuEntry("Something Else", "Do something else")); + .Add(new MenuEntry("Options", "Change game options")) + .Add(new MenuEntry("Exit", "Exit the game")); base.Activate(); } public override void SelectItem() { - Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav"); + base.SelectItem(); if (CursorPosition == 0) { Manager.AddScreen(new GameScreen()); Manager.RemoveScreen(this); Manager.Game.ResetElapsedTime(); } + if (CursorPosition == 2) + { + Environment.Exit(0); + } + if (CursorPosition == 1) + { + Manager.RemoveScreen(this); + Manager.AddScreen(new OptionsScreen()); + } } } } diff --git a/EvilSatellites/Screens/MenuScreen.cs b/EvilSatellites/Screens/MenuScreen.cs index 324d327..b96bbb0 100644 --- a/EvilSatellites/Screens/MenuScreen.cs +++ b/EvilSatellites/Screens/MenuScreen.cs @@ -96,6 +96,7 @@ namespace EvilSatellites.Screens public virtual void SelectItem() { + Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav"); return; } } diff --git a/EvilSatellites/Screens/OptionsScreen.cs b/EvilSatellites/Screens/OptionsScreen.cs new file mode 100644 index 0000000..2873912 --- /dev/null +++ b/EvilSatellites/Screens/OptionsScreen.cs @@ -0,0 +1,77 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EvilSatellites.Menu; +using DavyKager; + +namespace EvilSatellites.Screens +{ + public class OptionsScreen : MenuScreen + { + public override void Activate() + { + MenuOptions = new MenuContainer("Options", "Set global options for the game."); + MenuOptions.Add(new MenuEntry("Music Volume", "Toggle between music volumes")) + .Add(new MenuEntry("Use screen reader", "Use screen reader speech instead of SAPI")) + .Add(new MenuEntry("Back", "Go Back to previous screen")); + base.Activate(); + } + + public override void SelectItem() + { + base.SelectItem(); + if (CursorPosition == 0) + { + ChangeVolume(); + } + if (CursorPosition == 1) + { + ChangeSpeech(); + } + if (CursorPosition == 2) + { + Manager.RemoveScreen(this); + Manager.AddScreen(new MainMenuScreen()); + } + } + + public void ChangeSpeech() + { + if (GameSettings.PreferSAPI) + { + Tolk.PreferSAPI(false); + Tolk.TrySAPI(false); + Tolk.Output("Prefering screen reader"); + } else + { + Tolk.PreferSAPI(true); + Tolk.TrySAPI(true); + Tolk.Output("Prefering SAPI"); + } + } + + public void ChangeVolume() + { + Inputs.Update(); + if (Manager.Music.Volume > 0.9) + { + Manager.Music.Volume = 0f; + return; + } + if (Manager.Music.Volume < 0) + { + Manager.Music.Volume = 1; + } + if (Inputs.IsPressed(Microsoft.Xna.Framework.Input.Keys.LeftShift)) + { + Manager.Music.Volume = Manager.Music.Volume - 0.1f; + } else + { + Manager.Music.Volume = Manager.Music.Volume + 0.1f; + } + + } + } +} diff --git a/EvilSatellites/Screens/StatsScreen.cs b/EvilSatellites/Screens/StatsScreen.cs index 519a596..8b11d74 100644 --- a/EvilSatellites/Screens/StatsScreen.cs +++ b/EvilSatellites/Screens/StatsScreen.cs @@ -19,10 +19,12 @@ namespace EvilSatellites.Screens .Add(new MenuEntry("Satellite collisions: " + GameStats.SatelliteCollisions.ToString(), "How many satellites you crashed into")) .Add(new MenuEntry("Total play time: " + GameStats.TotalPlayTime.ToString(), "How much time you spent on this run")) .Add(new MenuEntry("OK", "Go back to main menu")); + base.Activate(); } public override void SelectItem() { + base.SelectItem(); if (CursorPosition == MenuOptions.Entries.Count-1) { Manager.RemoveScreen(this);