diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index a5563101ce..8dee81b601 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -5,7 +5,9 @@ using OpenRa.TechTree; using System.Drawing; using System.Linq; using IrrKlang; -using IjwFramework.Collections; +using IjwFramework.Collections; +using System; +using IjwFramework.Types; namespace OpenRa.Game { @@ -170,6 +172,14 @@ namespace OpenRa.Game return int.MaxValue; return BuildingInfluence.GetDistanceToBuilding(b); - } + } + + public static Random SharedRandom = new Random(); /* for things that require sync */ + public static Random CosmeticRandom = new Random(); /* for things that are just fluff */ + + public static readonly Pair SovietVoices = + Pair.New( + new VoicePool("ackno", "affirm1", "noprob", "overout", "ritaway", "roger", "ugotit"), + new VoicePool("await1", "ready", "report1", "yessir1")); } } diff --git a/OpenRa.Game/MoveOrder.cs b/OpenRa.Game/MoveOrder.cs index ccedbe37e7..d441b56368 100644 --- a/OpenRa.Game/MoveOrder.cs +++ b/OpenRa.Game/MoveOrder.cs @@ -18,13 +18,21 @@ namespace OpenRa.Game { this.Unit = unit; this.Destination = destination; + } + + string GetVoiceSuffix() + { + var suffixes = new[] { ".r01", ".r03" }; + return suffixes[Unit.traits.Get().Voice]; } public override void Apply( bool leftMouseButton ) { if (leftMouseButton) return; + if (Game.LocalPlayer == Unit.Owner) - Game.PlaySound("ackno.r00", false); + Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(), false); + var mobile = Unit.traits.Get(); mobile.destination = Destination; mobile.desiredFacing = null; diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 132ec45043..8f01a9917f 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -150,6 +150,7 @@ + diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index 8c16f986f1..f1d4b7da43 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits public int moveFraction, moveFractionTotal; public int facing; public int? desiredFacing; + public int Voice = Game.CosmeticRandom.Next(2); public Mobile(Actor self) { diff --git a/OpenRa.Game/VoicePool.cs b/OpenRa.Game/VoicePool.cs new file mode 100644 index 0000000000..100f655c77 --- /dev/null +++ b/OpenRa.Game/VoicePool.cs @@ -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 liveclips = new List(); + + 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; + } + } +}