voicepool to avoid annoying me with the same sound over and over... and units now have a voice assigned.

This commit is contained in:
Chris Forbes
2009-10-24 16:07:23 +13:00
parent aa784d446c
commit ea3526a238
5 changed files with 52 additions and 3 deletions

29
OpenRa.Game/VoicePool.cs Normal file
View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Game
{
class VoicePool
{
readonly string[] clips;
readonly List<string> liveclips = new List<string>();
public VoicePool(params string[] clips)
{
this.clips = clips;
}
public string GetNext()
{
if (liveclips.Count == 0)
liveclips.AddRange(clips);
var i = Game.CosmeticRandom.Next(liveclips.Count);
var s = liveclips[i];
liveclips.RemoveAt(i);
return s;
}
}
}