diff --git a/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 b/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 index a2e6059..3f04115 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 06cd66f..a69c84b 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 ed8a200..cceaefa 100644 --- a/EvilSatellites/EvilSatellites.csproj +++ b/EvilSatellites/EvilSatellites.csproj @@ -32,13 +32,13 @@ - ..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll + ..\..\synthy\Synthy\bin\Debug\netstandard2.1\CppSharp.Runtime.dll - ..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll + ..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthizer.Net.dll - ..\..\Synthizer\Synthy\bin\Debug\netstandard2.1\Synthy.dll + ..\..\synthy\Synthy\bin\Debug\netstandard2.1\Synthy.dll \ No newline at end of file diff --git a/EvilSatellites/Game1.cs b/EvilSatellites/Game1.cs index e6842d2..84afca3 100644 --- a/EvilSatellites/Game1.cs +++ b/EvilSatellites/Game1.cs @@ -23,7 +23,8 @@ namespace EvilSatellites protected override void Initialize() { // TODO: Add your initialization logic here - _manager.AddScreen(new EvilSatellites.Screens.GameScreen()); + // _manager.AddScreen(new EvilSatellites.Screens.GameScreen()); + _manager.AddScreen(new EvilSatellites.Screens.MainMenuScreen()); base.Initialize(); } diff --git a/EvilSatellites/Objects/Satellite.cs b/EvilSatellites/Objects/Satellite.cs index 96df7da..15a7605 100644 --- a/EvilSatellites/Objects/Satellite.cs +++ b/EvilSatellites/Objects/Satellite.cs @@ -50,14 +50,14 @@ namespace EvilSatellites.Objects { Move(new Vector3(0, 0, -0.05f)); Sound.Position = new System.Numerics.Vector3(Position.X+Dimensions.X/2, Position.Y+Dimensions.Y/2, Position.Z+Dimensions.Z/2); - if (rnd.Next(512) == 250) + if (rnd.Next(1024) == 512) { var scr = (GameScreen)Screen; var player = scr.GetPlayer(); var orient = Matrix.Invert(Matrix.CreateTranslation(Position) * Matrix.CreateLookAt(Position, scr.GetPlayer().Position, Rotation.Up)); var dir = Position - player.Position; dir.Normalize(); - + Screen.Manager.Sound.PlayOneshot(@"sfx/weapons/LaserCannon/fire/" + (rnd.Next(2) + 1).ToString() + ".wav", new System.Numerics.Vector3(Position.X + Dimensions.X / 2, Position.Y + Dimensions.Y / 2, Position.Z / Dimensions.Z / 2), Screen.Manager.EnvironmentEffect); var proj = new Projectile(Screen, Position, orient, this); // proj.Direction = dir; scr.AddObject(proj); diff --git a/EvilSatellites/ScreenManager.cs b/EvilSatellites/ScreenManager.cs index 68bff7d..4eb3f86 100644 --- a/EvilSatellites/ScreenManager.cs +++ b/EvilSatellites/ScreenManager.cs @@ -4,7 +4,6 @@ using System.Text; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; using SynthySound; -using Synthizer; using Microsoft.Xna.Framework.Audio; using EvilSatellites.Screens; @@ -14,6 +13,8 @@ namespace EvilSatellites public class ScreenManager : DrawableGameComponent { private List _Screens; + private List _ToRemove; + private List _ToAdd; private IScreen _CurrentScreen; private Game _Game; private bool _Running = false; @@ -29,9 +30,11 @@ namespace EvilSatellites EnvironmentEffect.T60 = 1; EnvironmentEffect.Defusion = 1f; EnvironmentEffect.FreePath = 0.02; - + Sound.SetMaxDistance(150); _Game = instance; _Screens = new List(); + _ToRemove = new List(); + _ToAdd = new List(); _CurrentScreen = null; } @@ -48,8 +51,7 @@ namespace EvilSatellites public void AddScreen(IScreen screen) { screen.Manager = this; - if (_Running) screen.Activate(); - _Screens.Add(screen); + _ToAdd.Add(screen); } public void RemoveScreen(IScreen screen) { @@ -57,12 +59,29 @@ namespace EvilSatellites { throw new Exception("Cannot remove a screen that isn't added to manager"); } - screen.Deactivate(); - _Screens.Remove(screen); + _ToRemove.Add(screen); } public void Update(GameTime gameTime) { + if (_ToAdd.Count > 0) + { + foreach (var screen in _ToAdd) + { + screen.Activate(); + _Screens.Add(screen); + } + _ToAdd.Clear(); + } + if (_ToRemove.Count > 0) + { + foreach (var screen in _ToRemove) + { + screen.Deactivate(); + _Screens.Remove(screen); + } + _ToRemove.Clear(); + } Sound.Update(); var input = Keyboard.GetState(); foreach (var screen in _Screens) diff --git a/EvilSatellites/Screens/GameScreen.cs b/EvilSatellites/Screens/GameScreen.cs index 11d2ba7..50711f9 100644 --- a/EvilSatellites/Screens/GameScreen.cs +++ b/EvilSatellites/Screens/GameScreen.cs @@ -30,8 +30,6 @@ namespace EvilSatellites.Screens Player player = new Player(this); Objects.Add(player); _player = player; - // Satellite prop = new Satellite(this, new Vector3(5000, 5000, 5000)); - // Objects.Add(prop); ObjectRadar = new Radar(_player, this); Spawner = new SatelliteSpawner(this); Spawner.Spawn(); diff --git a/EvilSatellites/Screens/MainMenuScreen.cs b/EvilSatellites/Screens/MainMenuScreen.cs new file mode 100644 index 0000000..0ca62d6 --- /dev/null +++ b/EvilSatellites/Screens/MainMenuScreen.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using EvilSatellites.Menu; +using EvilSatellites.Screens; + +namespace EvilSatellites.Screens +{ + public class MainMenuScreen : MenuScreen + { + public override void Activate() + { + + 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")); + base.Activate(); + } + + public override void SelectItem() + { + Manager.Sound.PlayOneshot(@"sfx/ui/menuChoose.wav"); + if (CursorPosition == 0) + { + Manager.AddScreen(new GameScreen()); + Manager.RemoveScreen(this); + Manager.Game.ResetElapsedTime(); + } + } + } +} diff --git a/EvilSatellites/Screens/MenuScreen.cs b/EvilSatellites/Screens/MenuScreen.cs index fb65861..9408e75 100644 --- a/EvilSatellites/Screens/MenuScreen.cs +++ b/EvilSatellites/Screens/MenuScreen.cs @@ -17,36 +17,33 @@ namespace EvilSatellites.Screens public ScreenManager _Manager; public ScreenState _State; public InputManager Inputs = new InputManager(); - public MenuScreen(ScreenManager manager, MenuContainer options) - { - _Manager = manager; - MenuOptions = options; - } - ScreenManager IScreen.Manager { get => _Manager; set => _Manager = value; } - ScreenState IScreen.State { get => _State; set => _State = value; } - void IScreen.Activate() + public ScreenManager Manager { get => _Manager; set => _Manager = value; } + public ScreenState State { get => _State; set => _State = value; } + + public virtual void Activate() { CursorPosition = 0; Tolk.Output(MenuOptions.Title, true); Tolk.Output(MenuOptions.Description, false); Tolk.Output(MenuOptions.Entries[CursorPosition].Name); + Manager.Sound.PlayOneshot(@"sfx/ui/menuOpen.wav"); } - void IScreen.Deactivate() + public virtual void Deactivate() { return; } - void IScreen.HandleInput(GameTime gameTime, KeyboardState inputs) + public void HandleInput(GameTime gameTime, KeyboardState inputs) { Inputs.Update(); if (Inputs.IsJustPressed(Keys.Down)) { NextItem(); } - if (Inputs.IsJustPressed(Keys.Down)) + if (Inputs.IsJustPressed(Keys.Up)) { PreviousItem(); } @@ -56,21 +53,22 @@ namespace EvilSatellites.Screens } } - void IScreen.Update(GameTime gameTime) + public virtual void Update(GameTime gameTime) { - return; + Manager.Sound.Update(); + } public void PreviousItem() { - CursorPosition--; + CursorPosition -= 1; CheckMenuBounds(); ReadMenuItem(); } public void NextItem() { - CursorPosition++; + CursorPosition += 1; CheckMenuBounds(); ReadMenuItem(); } @@ -80,19 +78,22 @@ namespace EvilSatellites.Screens if (CursorPosition > MenuOptions.Entries.Count-1) { CursorPosition = 0; + Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav"); } if (CursorPosition < 0) { - CursorPosition = MenuOptions.Entries.Count - 1; + CursorPosition = MenuOptions.Entries.Count-1; + Manager.Sound.PlayOneshot(@"sfx/ui/menuBoundary.wav"); } } public void ReadMenuItem() { + Manager.Sound.PlayOneshot(@"sfx/ui/menuMove.wav"); Tolk.Output(MenuOptions.Entries[CursorPosition].Name, true); } - public void SelectItem() + public virtual void SelectItem() { return; } diff --git a/EvilSatellites/Weapons/LaserMG.cs b/EvilSatellites/Weapons/LaserMG.cs index 0466e66..1306af5 100644 --- a/EvilSatellites/Weapons/LaserMG.cs +++ b/EvilSatellites/Weapons/LaserMG.cs @@ -56,7 +56,7 @@ namespace EvilSatellites.Weapons State = WeaponState.Starting; sfxSpinup.Reset(); sfxSpinup.Play(); - TimerStart = time.TotalGameTime.TotalMilliseconds; + TimerStart = 0; } public override void Stop() @@ -73,19 +73,19 @@ namespace EvilSatellites.Weapons public override void Update(GameTime time) { - TimerEnd += time.ElapsedGameTime.TotalMilliseconds; + TimerStart += time.ElapsedGameTime.TotalMilliseconds; if (State == WeaponState.Starting) { - if (TimerEnd - TimerStart > 800) + if (TimerStart > 800) { State = WeaponState.Firing; sfxSpinning.Play(); - TimerStart = TimerEnd; + TimerStart = 0; } } if (State == WeaponState.Firing) { - if (TimerEnd - TimerStart > FireRate) + if (TimerStart > FireRate) { if (RemainingAmmo > 0) { @@ -104,10 +104,10 @@ namespace EvilSatellites.Weapons } if (State == WeaponState.Stopping) { - if (TimerEnd - TimerStart > 500) + if (TimerStart > 500) { State = WeaponState.Stopped; - TimerStart = TimerEnd; + TimerStart = 0; } } base.Update(time);