move flash
This commit is contained in:
@@ -25,17 +25,24 @@ namespace OpenRa.Game
|
||||
|
||||
void ApplyOrders(float2 xy, MouseInput mi)
|
||||
{
|
||||
var doVoice = null as Actor;
|
||||
if (orderGenerator != null)
|
||||
foreach (var order in orderGenerator.Order(xy.ToInt2(), mi))
|
||||
{
|
||||
AddOrder( order );
|
||||
if (order.Subject != null && order.Player == Game.LocalPlayer)
|
||||
doVoice = order.Subject;
|
||||
}
|
||||
if (orderGenerator == null) return;
|
||||
|
||||
if (doVoice != null && doVoice.traits.Contains<Unit>())
|
||||
Sound.PlayVoice("Move", doVoice);
|
||||
var orders = orderGenerator.Order(xy.ToInt2(), mi).ToArray();
|
||||
recentOrders.AddRange( orders );
|
||||
|
||||
var voicedActor = orders.Select(o => o.Subject)
|
||||
.FirstOrDefault(a => a.Owner == Game.LocalPlayer && a.traits.Contains<Unit>());
|
||||
|
||||
var isMove = orders.Any(o => o.OrderString == "Move");
|
||||
var isAttack = orders.Any( o => o.OrderString == "Attack" );
|
||||
|
||||
if (voicedActor != null)
|
||||
{
|
||||
Sound.PlayVoice(isAttack ? "Attack" : "Move", voicedActor);
|
||||
|
||||
if (isMove)
|
||||
Game.world.Add(new Effects.MoveFlash(Game.CellSize * xy));
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOrder(Order o) { recentOrders.Add(o); }
|
||||
|
||||
30
OpenRa.Game/Effects/MoveFlash.cs
Normal file
30
OpenRa.Game/Effects/MoveFlash.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Graphics;
|
||||
using OpenRa.Game.Traits;
|
||||
|
||||
namespace OpenRa.Game.Effects
|
||||
{
|
||||
class MoveFlash : IEffect
|
||||
{
|
||||
Animation anim = new Animation("moveflsh");
|
||||
float2 pos;
|
||||
|
||||
public MoveFlash( float2 pos )
|
||||
{
|
||||
this.pos = pos;
|
||||
anim.PlayThen( "idle",
|
||||
() => Game.world.AddFrameEndTask(
|
||||
w => w.Remove( this ) ) );
|
||||
}
|
||||
|
||||
public void Tick() { anim.Tick(); }
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
yield return new Renderable(anim.Image, pos - .5f * anim.Image.size, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,6 +81,7 @@
|
||||
<Compile Include="Chrome.cs" />
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
<Compile Include="Effects\TeslaZap.cs" />
|
||||
<Compile Include="Exts.cs" />
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- openra/sequences.xml
|
||||
|
||||
this file describes animation sequences for structures and units.
|
||||
@@ -535,13 +535,13 @@
|
||||
<sequence name="medic" start="20" length="1" />
|
||||
<sequence name="ready" start="3" length="1" />
|
||||
<sequence name="hold" start="4" length="1" />
|
||||
<sequence name="pip-empty" start="0" length="1" />
|
||||
<sequence name="pip-green" start="1" length="1" />
|
||||
<sequence name="pip-empty" start="0" length="1" />
|
||||
<sequence name="pip-green" start="1" length="1" />
|
||||
<sequence name="pip-yellow" start="5" length="1" />
|
||||
<sequence name="pip-gray" start="6" length="1" />
|
||||
<sequence name="pip-red" start="7" length="1" />
|
||||
<sequence name="tag-fake" start="18" length="1" />
|
||||
<sequence name="tag-primary" start="2" length="1" />
|
||||
<sequence name="tag-primary" start="2" length="1" />
|
||||
</unit>
|
||||
<unit name="mig">
|
||||
<sequence name="idle" start="0" length="16" />
|
||||
@@ -888,4 +888,7 @@
|
||||
<sequence name="crawl-6" start="96" length="4" />
|
||||
<sequence name="crawl-7" start="100" length="4" />
|
||||
</unit>
|
||||
<unit name="moveflsh">
|
||||
<sequence name="idle" start="0" length="5" />
|
||||
</unit>
|
||||
</sequences>
|
||||
Reference in New Issue
Block a user