diff --git a/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 b/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 index 3f04115..55fcb8f 100644 Binary files a/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 and b/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 differ diff --git a/.vs/EvilSatellites/v16/.suo b/.vs/EvilSatellites/v16/.suo index a69c84b..1691341 100644 Binary files a/.vs/EvilSatellites/v16/.suo and b/.vs/EvilSatellites/v16/.suo differ diff --git a/EvilSatellites/EvilSatellites.csproj b/EvilSatellites/EvilSatellites.csproj index cceaefa..902b24d 100644 --- a/EvilSatellites/EvilSatellites.csproj +++ b/EvilSatellites/EvilSatellites.csproj @@ -32,13 +32,13 @@ - ..\..\synthy\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll + ..\..\synthy\Synthy\bin\Release\netstandard2.1\CppSharp.Runtime.dll - ..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll + ..\..\synthy\Synthy\bin\Release\netstandard2.1\Synthizer.Net.dll - ..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthy.dll + ..\..\synthy\Synthy\bin\Release\netstandard2.1\Synthy.dll \ No newline at end of file diff --git a/EvilSatellites/GameStats.cs b/EvilSatellites/GameStats.cs new file mode 100644 index 0000000..8bbe365 --- /dev/null +++ b/EvilSatellites/GameStats.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EvilSatellites +{ + public static class GameStats + { + public static int ShotsFired; + public static int SatellitesShot; + public static int DebrisCollected; + public static int SatelliteCollisions; + public static int DebrisCollisions; + public static double TotalPlayTime; + public static void Reset() + { + ShotsFired = 0; + SatellitesShot = 0; + DebrisCollected = 0; + SatelliteCollisions = 0; + DebrisCollisions = 0; + TotalPlayTime = 0; + + } + } +} diff --git a/EvilSatellites/MusicManager.cs b/EvilSatellites/MusicManager.cs new file mode 100644 index 0000000..f7d9bac --- /dev/null +++ b/EvilSatellites/MusicManager.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SynthySound; + +namespace EvilSatellites +{ + public class MusicManager + { + public ISoundEffect Song; + public float _Volume; + public float Volume { + get => _Volume; + set + { + if (IsPlaying) + { + Song.Volume = Volume; + } + _Volume = Volume; + } + } + public bool IsPlaying; + public Synthy Engine; + public MusicManager(Synthy engine) + { + Engine = engine; + _Volume = 0.2f; + IsPlaying = false; + } + + public void Play(string path) + { + if (IsPlaying) + { + Song.Stop(); + Song.Destroy(); + } + Song = Engine.Load(@"sfx/music/" + path + ".mp3", false, true); + + Song.Play(); + Song.Volume = _Volume; + Song.Loop = true; + IsPlaying = true; + } + + public void Stop() + { + if (IsPlaying) + { + Song.Stop(); + Song.Destroy(); + IsPlaying = false; + } + } + } +} diff --git a/EvilSatellites/Objects/Debris.cs b/EvilSatellites/Objects/Debris.cs index 5b4deb3..3e8bc0c 100644 --- a/EvilSatellites/Objects/Debris.cs +++ b/EvilSatellites/Objects/Debris.cs @@ -58,10 +58,12 @@ namespace EvilSatellites.Objects { player.CurrentWeapon.Reload(rnd.Next(player.CurrentWeapon.MaxAmmo/4)); Destroy(); + GameStats.DebrisCollected++; return; } player.TakeDamage(25); Destroy(); + GameStats.SatelliteCollisions++; } } } diff --git a/EvilSatellites/Objects/Player.cs b/EvilSatellites/Objects/Player.cs index 10939f0..d314200 100644 --- a/EvilSatellites/Objects/Player.cs +++ b/EvilSatellites/Objects/Player.cs @@ -207,8 +207,8 @@ namespace EvilSatellites.Objects { Destroy(); Screen.Manager.Sound.PlayOneshot(@"sfx/physics/crashes/1.wav"); - System.Threading.Thread.Sleep(2000); - Environment.Exit(0); + var scr = (GameScreen)Screen; + scr.EndGame(); } } diff --git a/EvilSatellites/Objects/Satellite.cs b/EvilSatellites/Objects/Satellite.cs index 15a7605..0679bc3 100644 --- a/EvilSatellites/Objects/Satellite.cs +++ b/EvilSatellites/Objects/Satellite.cs @@ -83,6 +83,7 @@ namespace EvilSatellites.Objects Screen.Manager.Sound.PlayOneshot(@"sfx/satellite/"+SatelliteID.ToString()+"/explode.wav", new System.Numerics.Vector3(Position.X, Position.Y, Position.Z)); SpawnDebris(); Destroy(); + GameStats.SatellitesShot++; } } diff --git a/EvilSatellites/Radar.cs b/EvilSatellites/Radar.cs index 31332bb..d1ae6d3 100644 --- a/EvilSatellites/Radar.cs +++ b/EvilSatellites/Radar.cs @@ -122,5 +122,9 @@ namespace EvilSatellites } } + public void Destroy() + { + RadarNoise.Destroy(); + } } } diff --git a/EvilSatellites/SatelliteSpawner.cs b/EvilSatellites/SatelliteSpawner.cs index db07c81..bdeacc9 100644 --- a/EvilSatellites/SatelliteSpawner.cs +++ b/EvilSatellites/SatelliteSpawner.cs @@ -43,5 +43,10 @@ namespace EvilSatellites Spawn(); } } + + public void Destroy() + { + return; + } } } diff --git a/EvilSatellites/ScreenManager.cs b/EvilSatellites/ScreenManager.cs index 4eb3f86..e244454 100644 --- a/EvilSatellites/ScreenManager.cs +++ b/EvilSatellites/ScreenManager.cs @@ -18,12 +18,14 @@ namespace EvilSatellites private IScreen _CurrentScreen; private Game _Game; private bool _Running = false; - public Synthy Sound = new Synthy(); - + public Synthy Sound; + public MusicManager Music; public FDNReverb EnvironmentEffect; public AudioListener Listener = new AudioListener(); public ScreenManager(Game instance): base(instance) { + Sound = new Synthy(); + Music = new MusicManager(Sound); EnvironmentEffect = Sound.CreateReverb(); EnvironmentEffect.Delay = 0.03; EnvironmentEffect.Wet = 30; diff --git a/EvilSatellites/Screens/GameScreen.cs b/EvilSatellites/Screens/GameScreen.cs index 50711f9..7ea475a 100644 --- a/EvilSatellites/Screens/GameScreen.cs +++ b/EvilSatellites/Screens/GameScreen.cs @@ -24,6 +24,7 @@ namespace EvilSatellites.Screens private Player _player; private Radar ObjectRadar; private SatelliteSpawner Spawner; + private bool GameOver = false; public void Activate() { State = ScreenState.Active; @@ -33,6 +34,8 @@ namespace EvilSatellites.Screens ObjectRadar = new Radar(_player, this); Spawner = new SatelliteSpawner(this); Spawner.Spawn(); + GameStats.Reset(); + Manager.Music.Play("game1"); return; } @@ -44,6 +47,19 @@ namespace EvilSatellites.Screens public void Update(GameTime gameTime) { + if (GameOver == true) + { + foreach (var obj in Objects) + { + obj.Destroy(); + } + ObjectRadar.Destroy(); + Spawner.Destroy(); + // TODO: figure out why cleanup doesn't work + // Manager.Sound.Cleanup(); + HandleGameOver(gameTime); + + } foreach (var obj in Removable) { Objects.Remove(obj); @@ -241,5 +257,17 @@ namespace EvilSatellites.Screens { return _player; } + + public void HandleGameOver(GameTime time) + { + GameStats.TotalPlayTime = time.TotalGameTime.TotalSeconds; + Manager.RemoveScreen(this); + Manager.AddScreen(new StatsScreen()); + } + + public void EndGame() + { + GameOver = true; + } } } diff --git a/EvilSatellites/Screens/MenuScreen.cs b/EvilSatellites/Screens/MenuScreen.cs index 9408e75..324d327 100644 --- a/EvilSatellites/Screens/MenuScreen.cs +++ b/EvilSatellites/Screens/MenuScreen.cs @@ -29,6 +29,7 @@ namespace EvilSatellites.Screens Tolk.Output(MenuOptions.Description, false); Tolk.Output(MenuOptions.Entries[CursorPosition].Name); Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav"); + Manager.Music.Play("menu1"); } public virtual void Deactivate() diff --git a/EvilSatellites/Screens/StatsScreen.cs b/EvilSatellites/Screens/StatsScreen.cs new file mode 100644 index 0000000..519a596 --- /dev/null +++ b/EvilSatellites/Screens/StatsScreen.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EvilSatellites.Screens; +using EvilSatellites.Menu; + +namespace EvilSatellites.Screens +{ + public class StatsScreen : MenuScreen + { + public override void Activate() + { + MenuOptions = new MenuContainer("Statistics", "Statistics for current game"); + MenuOptions.Add(new MenuEntry("Shots fired: " + GameStats.ShotsFired.ToString(), "Amount of shots fired during this game.")) + .Add(new MenuEntry("Satellites shot: " + GameStats.SatellitesShot.ToString(), "Amount of satellites shot during this game.")) + .Add(new MenuEntry("Debris collected: " + GameStats.DebrisCollected.ToString(), "Amount of debris collected during this game.")) + .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")); + } + + public override void SelectItem() + { + if (CursorPosition == MenuOptions.Entries.Count-1) + { + Manager.RemoveScreen(this); + Manager.AddScreen(new MainMenuScreen()); + } + } + } +} diff --git a/EvilSatellites/Weapons/LaserMG.cs b/EvilSatellites/Weapons/LaserMG.cs index 1306af5..b6a3aec 100644 --- a/EvilSatellites/Weapons/LaserMG.cs +++ b/EvilSatellites/Weapons/LaserMG.cs @@ -94,6 +94,7 @@ namespace EvilSatellites.Weapons TimerStart = TimerEnd; Projectile proj = new Projectile(Screen, _wielder.Position, _wielder.Rotation, _wielder); Screen.AddObject(proj); + GameStats.ShotsFired++; } else { sfxEmpty.Reset(); diff --git a/EvilSatellites/sfx/music/game1.flac b/EvilSatellites/sfx/music/game1.flac new file mode 100644 index 0000000..a2d84b1 Binary files /dev/null and b/EvilSatellites/sfx/music/game1.flac differ diff --git a/EvilSatellites/sfx/music/game1.mp3 b/EvilSatellites/sfx/music/game1.mp3 new file mode 100644 index 0000000..b339ab4 Binary files /dev/null and b/EvilSatellites/sfx/music/game1.mp3 differ diff --git a/EvilSatellites/sfx/music/menu1.flac b/EvilSatellites/sfx/music/menu1.flac new file mode 100644 index 0000000..ea9b382 Binary files /dev/null and b/EvilSatellites/sfx/music/menu1.flac differ diff --git a/EvilSatellites/sfx/music/menu1.mp3 b/EvilSatellites/sfx/music/menu1.mp3 new file mode 100644 index 0000000..1005ccb Binary files /dev/null and b/EvilSatellites/sfx/music/menu1.mp3 differ