it works
This commit is contained in:
@@ -24,8 +24,30 @@ namespace OpenRa.Game
|
||||
if (order.Subject != null && order.Player == Game.LocalPlayer)
|
||||
doVoice = order.Subject;
|
||||
}
|
||||
|
||||
if (doVoice != null && doVoice.traits.Contains<Unit>())
|
||||
Game.PlaySound(Game.SovietVoices.First.GetNext() + GetVoiceSuffix(doVoice), false);
|
||||
PlayVoiceClip("Move", doVoice);
|
||||
}
|
||||
|
||||
static void PlayVoiceClip(string phrase, Actor voicedUnit)
|
||||
{
|
||||
if (voicedUnit == null) return;
|
||||
|
||||
var mi = voicedUnit.unitInfo as MobileInfo;
|
||||
if (mi == null) return;
|
||||
|
||||
var vi = Rules.VoiceInfo[ mi.Voice ];
|
||||
|
||||
var clip = vi.Pools.Value[phrase].GetNext();
|
||||
if (clip == null)
|
||||
return;
|
||||
|
||||
var variants = (voicedUnit.Owner.Race == Race.Soviet)
|
||||
? vi.SovietVariants : vi.AlliedVariants;
|
||||
|
||||
var variant = variants[ voicedUnit.ActorID % variants.Length ];
|
||||
|
||||
Game.PlaySound(clip + variant, false);
|
||||
}
|
||||
|
||||
public void AddOrder(Order o) { recentOrders.Add(o); }
|
||||
@@ -79,8 +101,7 @@ namespace OpenRa.Game
|
||||
&& a.Owner == Game.LocalPlayer)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (voicedUnit != null)
|
||||
Game.PlaySound(Game.SovietVoices.Second.GetNext() + GetVoiceSuffix(voicedUnit), false);
|
||||
PlayVoiceClip("Select", voicedUnit);
|
||||
}
|
||||
|
||||
dragStart = dragEnd = xy;
|
||||
|
||||
@@ -291,11 +291,6 @@ namespace OpenRa.Game
|
||||
public static Random SharedRandom = new Random(0); /* for things that require sync */
|
||||
public static Random CosmeticRandom = new Random(); /* for things that are just fluff */
|
||||
|
||||
public static readonly Pair<VoicePool, VoicePool> SovietVoices =
|
||||
Pair.New(
|
||||
new VoicePool("ackno", "affirm1", "noprob", "overout", "ritaway", "roger", "ugotit"),
|
||||
new VoicePool("await1", "ready", "report1", "yessir1"));
|
||||
|
||||
public static int2? FindAdjacentTile(Actor a, UnitMovementType umt)
|
||||
{
|
||||
var tiles = Footprint.Tiles(a, a.traits.Get<Traits.Building>());
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using IjwFramework.Types;
|
||||
using IjwFramework.Collections;
|
||||
|
||||
namespace OpenRa.Game.GameRules
|
||||
{
|
||||
@@ -12,5 +14,18 @@ namespace OpenRa.Game.GameRules
|
||||
public readonly string[] Select = {};
|
||||
public readonly string[] Move = {};
|
||||
public readonly string[] Attack = null;
|
||||
|
||||
public readonly Lazy<Dictionary<string, VoicePool>> Pools;
|
||||
|
||||
public VoiceInfo()
|
||||
{
|
||||
Pools = Lazy.New(() =>
|
||||
new Dictionary<string, VoicePool>
|
||||
{
|
||||
{ "Select", new VoicePool(Select) },
|
||||
{ "Move", new VoicePool(Move) },
|
||||
{ "Attack", new VoicePool( Attack ?? Move ) },
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@ namespace OpenRa.Game
|
||||
if (liveclips.Count == 0)
|
||||
liveclips.AddRange(clips);
|
||||
|
||||
if (liveclips.Count == 0)
|
||||
return null; /* avoid crashing if there's no clips at all */
|
||||
|
||||
var i = Game.CosmeticRandom.Next(liveclips.Count);
|
||||
var s = liveclips[i];
|
||||
liveclips.RemoveAt(i);
|
||||
|
||||
Reference in New Issue
Block a user