voicepool to avoid annoying me with the same sound over and over... and units now have a voice assigned.
This commit is contained in:
@@ -6,6 +6,8 @@ using System.Drawing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using IrrKlang;
|
using IrrKlang;
|
||||||
using IjwFramework.Collections;
|
using IjwFramework.Collections;
|
||||||
|
using System;
|
||||||
|
using IjwFramework.Types;
|
||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
@@ -171,5 +173,13 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
return BuildingInfluence.GetDistanceToBuilding(b);
|
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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,19 @@ namespace OpenRa.Game
|
|||||||
this.Destination = destination;
|
this.Destination = destination;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string GetVoiceSuffix()
|
||||||
|
{
|
||||||
|
var suffixes = new[] { ".r01", ".r03" };
|
||||||
|
return suffixes[Unit.traits.Get<Traits.Mobile>().Voice];
|
||||||
|
}
|
||||||
|
|
||||||
public override void Apply( bool leftMouseButton )
|
public override void Apply( bool leftMouseButton )
|
||||||
{
|
{
|
||||||
if (leftMouseButton) return;
|
if (leftMouseButton) return;
|
||||||
|
|
||||||
if (Game.LocalPlayer == Unit.Owner)
|
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>();
|
var mobile = Unit.traits.Get<Traits.Mobile>();
|
||||||
mobile.destination = Destination;
|
mobile.destination = Destination;
|
||||||
mobile.desiredFacing = null;
|
mobile.desiredFacing = null;
|
||||||
|
|||||||
@@ -150,6 +150,7 @@
|
|||||||
<Compile Include="Graphics\Vertex.cs" />
|
<Compile Include="Graphics\Vertex.cs" />
|
||||||
<Compile Include="Graphics\Viewport.cs" />
|
<Compile Include="Graphics\Viewport.cs" />
|
||||||
<Compile Include="UnitOrderGenerator.cs" />
|
<Compile Include="UnitOrderGenerator.cs" />
|
||||||
|
<Compile Include="VoicePool.cs" />
|
||||||
<Compile Include="World.cs" />
|
<Compile Include="World.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public int moveFraction, moveFractionTotal;
|
public int moveFraction, moveFractionTotal;
|
||||||
public int facing;
|
public int facing;
|
||||||
public int? desiredFacing;
|
public int? desiredFacing;
|
||||||
|
public int Voice = Game.CosmeticRandom.Next(2);
|
||||||
|
|
||||||
public Mobile(Actor self)
|
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