Some of fixing #36

This commit is contained in:
alzeih
2010-08-14 20:11:03 +12:00
parent 8c39e372e3
commit 7a10ae3dea
6 changed files with 19 additions and 18 deletions

View File

@@ -9,14 +9,14 @@
#endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.FileFormats;
namespace OpenRA.GameRules
{
public class VoiceInfo
{
public readonly string[] SovietVariants = { ".aud" };
public readonly string[] AlliedVariants = { ".aud" };
public readonly Dictionary<string,string[]> Variants;
public readonly string[] Select = { };
public readonly string[] Move = { };
public readonly string[] Attack = null;
@@ -26,7 +26,10 @@ namespace OpenRA.GameRules
public VoiceInfo( MiniYaml y )
{
FieldLoader.Load(this, y);
FieldLoader.LoadFields(this, y.Nodes, new string[] { "Select", "Move", "Attack", "Die" });
Variants = (y.Nodes.ContainsKey("Variants"))? y.Nodes["Variants"].Nodes.ToDictionary(a => a.Key,
a => (string[])FieldLoader.GetValue( "(value)", typeof(string[]), a.Value.Value ))
: new Dictionary<string, string[]>();
Pools = Lazy.New(() =>
new Dictionary<string, VoicePool>

View File

@@ -42,7 +42,8 @@ namespace OpenRA
actors = (isCombine ? oldSelection.Union(newSelection) : newSelection).ToList();
var voicedUnit = actors.FirstOrDefault(a => a.Owner == world.LocalPlayer && a.HasVoice());
Sound.PlayVoice("Select", voicedUnit);
if (voicedUnit != null)
Sound.PlayVoice("Select", voicedUnit, voicedUnit.Owner.Country.Race);
foreach (var ns in world.WorldActor.TraitsImplementing<INotifySelection>())
ns.SelectionChanged();

View File

@@ -182,7 +182,7 @@ namespace OpenRA
}
// Returns true if it played a phrase
public static bool PlayVoice(string phrase, Actor voicedUnit)
public static bool PlayVoice(string phrase, Actor voicedUnit, string variant)
{
if (voicedUnit == null) return false;
if (phrase == null) return false;
@@ -203,13 +203,8 @@ namespace OpenRA
return true;
}
// todo: fix this
var variants = (voicedUnit.Owner.Country.Race == "allies")
? vi.AlliedVariants : vi.SovietVariants;
var variant = variants[voicedUnit.ActorID % variants.Length];
Play(clip + variant);
var variantext = vi.Variants[variant][voicedUnit.ActorID % vi.Variants.Count];
Play(clip + variantext);
return true;
}
}

View File

@@ -98,7 +98,7 @@ namespace OpenRA.Widgets
{
foreach (var v in o.Subject.TraitsImplementing<IOrderVoice>())
{
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject))
if (Sound.PlayVoice(v.VoicePhraseForOrder(o.Subject, o), o.Subject, o.Subject.Owner.Country.Race))
{
done = true;
break;

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.Render
if (e.DamageState == DamageState.Dead)
{
var death = e.Warhead != null ? e.Warhead.InfDeath : 0;
Sound.PlayVoice("Die", self);
Sound.PlayVoice("Die", self, self.Owner.Country.Race);
self.World.AddFrameEndTask(w => w.Add(new Corpse(self, death)));
}
}

View File

@@ -1,13 +1,15 @@
GenericVoice:
SovietVariants: .v01,.v03
AlliedVariants: .v01,.v03
Variants:
nod: .v01,.v03
gdi: .v01,.v03
Select: await1,ready,report1,yessir1
Move: ackno,affirm1,noprob,ritaway,roger,ugotit
Die: nuyell1.aud,nuyell3.aud,nuyell4.aud,nuyell5.aud
VehicleVoice:
SovietVariants: .v00,.v02
AlliedVariants: .v00,.v02
Variants:
nod: .v00,.v02
gdi: .v00,.v02
Select: vehic1,yessir1,report1,await1,unit1
Move: ackno,affirm1,movout1