voicepool to avoid annoying me with the same sound over and over... and units now have a voice assigned.
This commit is contained in:
@@ -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<VoicePool, VoicePool> SovietVoices =
|
||||
Pair.New(
|
||||
new VoicePool("ackno", "affirm1", "noprob", "overout", "ritaway", "roger", "ugotit"),
|
||||
new VoicePool("await1", "ready", "report1", "yessir1"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<Traits.Mobile>().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<Traits.Mobile>();
|
||||
mobile.destination = Destination;
|
||||
mobile.desiredFacing = null;
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<Compile Include="Graphics\Vertex.cs" />
|
||||
<Compile Include="Graphics\Viewport.cs" />
|
||||
<Compile Include="UnitOrderGenerator.cs" />
|
||||
<Compile Include="VoicePool.cs" />
|
||||
<Compile Include="World.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
29
OpenRa.Game/VoicePool.cs
Normal file
29
OpenRa.Game/VoicePool.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user