diff --git a/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 b/.vs/EvilSatellites/DesignTimeBuild/.dtbcache.v2 index 6e23536..8bdbb19 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 53a0092..ebc2428 100644 Binary files a/.vs/EvilSatellites/v16/.suo and b/.vs/EvilSatellites/v16/.suo differ diff --git a/EvilSatellites/AI.cs b/EvilSatellites/AI.cs new file mode 100644 index 0000000..27ce653 --- /dev/null +++ b/EvilSatellites/AI.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SynthySound; + +namespace EvilSatellites +{ + public class AI + { + public Synthy Engine; + public Dictionary Clips; + public Random rnd = new Random(); + public AI(Synthy engine) + { + Engine = engine; + Clips = new Dictionary(); + SetupClips(); + } + + public void SetupClips() + { + Clips.Add("GameStart", new AIVoiceClip + { + Name = "GameStart", + NumFiles = 3, + Probability = new int[2] { 1, 1 } + }); + + Clips.Add("CollectDebris", new AIVoiceClip + { + Name = "CollectDebris", + NumFiles = 3, + Probability = new int[2] { 5, 10 } + }); + + Clips.Add("DamageBullet", new AIVoiceClip + { + Name = "DamageBullet", + NumFiles = 4, + Probability = new int[2] { 5, 10 } + }); + + Clips.Add("DamageDebris", new AIVoiceClip + { + Name = "DamageDebris", + NumFiles = 3, + Probability = new int[2] { 2, 4 } + }); + + // TODO + Clips.Add("FarMiss", new AIVoiceClip + { + Name = "FarMiss", + NumFiles = 6, + Probability = new int[2] { 5, 50 } + }); + + Clips.Add("GameOver", new AIVoiceClip + { + Name = "GameOver", + NumFiles = 4, + Probability = new int[2] { 1, 1 } + }); + + Clips.Add("Hit", new AIVoiceClip + { + Name = "Hit", + NumFiles = 5, + Probability = new int[2] { 5, 20 } + }); + + Clips.Add("LowHealth", new AIVoiceClip + { + Name = "LowHealth", + NumFiles = 5, + Probability = new int[2] { 1, 3 } + }); + + // TODO + Clips.Add("NearMiss", new AIVoiceClip + { + Name = "NearMiss", + NumFiles = 4, + Probability = new int[2] { 50, 100 } + }); + + // TODO + Clips.Add("Spinning", new AIVoiceClip + { + Name = "Spinning", + NumFiles = 2, + Probability = new int[2] { 2, 4 } + }); + + // TODO + Clips.Add("Still", new AIVoiceClip + { + Name = "Still", + NumFiles = 5, + Probability = new int[2] { 2, 4 } + }); + + // TODO + Clips.Add("Void", new AIVoiceClip + { + Name = "Void", + NumFiles = 3, + Probability = new int[2] { 50, 200 } + }); + + Clips.Add("Wave", new AIVoiceClip + { + Name = "Wave", + NumFiles = 4, + Probability = new int[2] { 1, 2 } + }); + } + + public void Play(string name) + { + if (Clips.ContainsKey(name)) + { + var clip = Clips[name]; + var prob = rnd.Next(clip.Probability[1]); + if (prob == clip.Probability[0] || (clip.Probability[0] == 1 && clip.Probability[1] == 1)) + { + var file = rnd.Next(clip.NumFiles - 1) + 1; + Engine.PlayOneshot(@"sfx/ai/" + name + file.ToString() + ".wav"); + } + } + } + } + public struct AIVoiceClip + { + public string Name; + public int NumFiles; + public int[] Probability; + } +} diff --git a/EvilSatellites/Objects/Debris.cs b/EvilSatellites/Objects/Debris.cs index 8b30d70..17fb507 100644 --- a/EvilSatellites/Objects/Debris.cs +++ b/EvilSatellites/Objects/Debris.cs @@ -57,7 +57,7 @@ namespace EvilSatellites.Objects if (player.Vacuuming) { player.CurrentWeapon.Reload(rnd.Next(player.CurrentWeapon.MaxAmmo/4)); - + Screen.Manager.Computer.Play("CollectDebris"); Destroy(); GameStats.DebrisCollected++; return; diff --git a/EvilSatellites/Objects/Player.cs b/EvilSatellites/Objects/Player.cs index f7ac0bd..0eee4b3 100644 --- a/EvilSatellites/Objects/Player.cs +++ b/EvilSatellites/Objects/Player.cs @@ -189,6 +189,7 @@ namespace EvilSatellites.Objects { IsDamaged = true; sfxDamage.Play(); + Screen.Manager.Computer.Play("LowHealth"); } string dmgSound = @"sfx/physics/collisions/"; if (dmg > 60) @@ -231,10 +232,15 @@ namespace EvilSatellites.Objects override public void OnCollision(IGameObject obj) { + if (obj.Type == ObjectType.Debris) + { + Screen.Manager.Computer.Play("DamageDebris"); + } if (obj.Type == ObjectType.Projectile) { var proj = (Projectile)obj; if (proj.Owner == this) return; + Screen.Manager.Computer.Play("DamageBullet"); TakeDamage(rnd.Next(20)); } } diff --git a/EvilSatellites/Objects/Satellite.cs b/EvilSatellites/Objects/Satellite.cs index 0679bc3..0a6962d 100644 --- a/EvilSatellites/Objects/Satellite.cs +++ b/EvilSatellites/Objects/Satellite.cs @@ -70,6 +70,11 @@ namespace EvilSatellites.Objects { var proj = (Projectile)obj; if (proj.Owner == this) return; + var scr = (GameScreen)Screen; + if (proj.Owner == scr.GetPlayer()) + { + scr.Manager.Computer.Play("Hit"); + } } Health -= 10; if (obj.Type == ObjectType.Player) diff --git a/EvilSatellites/SatelliteSpawner.cs b/EvilSatellites/SatelliteSpawner.cs index 031986a..cba3e98 100644 --- a/EvilSatellites/SatelliteSpawner.cs +++ b/EvilSatellites/SatelliteSpawner.cs @@ -54,6 +54,7 @@ namespace EvilSatellites GameStats.Wave++; Level++; Spawn(); + Screen.Manager.Computer.Play("Wave"); } } diff --git a/EvilSatellites/ScreenManager.cs b/EvilSatellites/ScreenManager.cs index 7f1f7fc..7816c78 100644 --- a/EvilSatellites/ScreenManager.cs +++ b/EvilSatellites/ScreenManager.cs @@ -20,12 +20,14 @@ namespace EvilSatellites private bool _Running = false; public Synthy Sound; public MusicManager Music; + public AI Computer; public VibrationManager Vibrations; public FDNReverb EnvironmentEffect; public ScreenManager(Game instance): base(instance) { Sound = new Synthy(); Music = new MusicManager(Sound); + Computer = new AI(Sound); Vibrations = new VibrationManager(PlayerIndex.One); EnvironmentEffect = Sound.CreateReverb(); EnvironmentEffect.Delay = 0.03; @@ -48,7 +50,6 @@ namespace EvilSatellites { screen.Activate(); } - Vibrations.AddVibration(1, 1, 500); base.Initialize(); } diff --git a/EvilSatellites/Screens/GameScreen.cs b/EvilSatellites/Screens/GameScreen.cs index c4ba770..f7c7976 100644 --- a/EvilSatellites/Screens/GameScreen.cs +++ b/EvilSatellites/Screens/GameScreen.cs @@ -36,6 +36,7 @@ namespace EvilSatellites.Screens Spawner.Spawn(); GameStats.Reset(); Manager.Music.Play("game1"); + Manager.Computer.Play("GameStart"); return; } @@ -56,7 +57,7 @@ namespace EvilSatellites.Screens ObjectRadar.Destroy(); Spawner.Destroy(); // TODO: figure out why cleanup doesn't work - // Manager.Sound.Cleanup(); + Manager.Sound.Cleanup(); HandleGameOver(gameTime); } @@ -277,6 +278,7 @@ namespace EvilSatellites.Screens public void EndGame() { GameOver = true; + Manager.Computer.Play("GameOver"); } } } diff --git a/EvilSatellites/sfx/ai/Damage1.wav b/EvilSatellites/sfx/ai/DamageBullet1.wav similarity index 100% rename from EvilSatellites/sfx/ai/Damage1.wav rename to EvilSatellites/sfx/ai/DamageBullet1.wav diff --git a/EvilSatellites/sfx/ai/Damage2.wav b/EvilSatellites/sfx/ai/DamageBullet2.wav similarity index 100% rename from EvilSatellites/sfx/ai/Damage2.wav rename to EvilSatellites/sfx/ai/DamageBullet2.wav diff --git a/EvilSatellites/sfx/ai/Damage3.wav b/EvilSatellites/sfx/ai/DamageBullet3.wav similarity index 100% rename from EvilSatellites/sfx/ai/Damage3.wav rename to EvilSatellites/sfx/ai/DamageBullet3.wav diff --git a/EvilSatellites/sfx/ai/Damage4.wav b/EvilSatellites/sfx/ai/DamageBullet4.wav similarity index 100% rename from EvilSatellites/sfx/ai/Damage4.wav rename to EvilSatellites/sfx/ai/DamageBullet4.wav