Add most AI lines

This commit is contained in:
2021-04-24 18:47:51 +02:00
parent b4f2e85503
commit a7765e5355
13 changed files with 159 additions and 3 deletions
+141
View File
@@ -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;
}
}