Add most AI lines
This commit is contained in:
@@ -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<string, AIVoiceClip> Clips;
|
||||
public Random rnd = new Random();
|
||||
public AI(Synthy engine)
|
||||
{
|
||||
Engine = engine;
|
||||
Clips = new Dictionary<string, AIVoiceClip>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace EvilSatellites
|
||||
GameStats.Wave++;
|
||||
Level++;
|
||||
Spawn();
|
||||
Screen.Manager.Computer.Play("Wave");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user