flash target on attack
This commit is contained in:
35
OpenRa.Game/Effects/FlashTarget.cs
Normal file
35
OpenRa.Game/Effects/FlashTarget.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRa.Game.Traits;
|
||||
using OpenRa.Game.Graphics;
|
||||
|
||||
namespace OpenRa.Game.Effects
|
||||
{
|
||||
class FlashTarget : IEffect
|
||||
{
|
||||
Actor target;
|
||||
int remainingTicks = 4;
|
||||
|
||||
public FlashTarget(Actor target)
|
||||
{
|
||||
this.target = target;
|
||||
foreach (var e in Game.world.Effects.OfType<FlashTarget>().Where(a => a.target == target).ToArray())
|
||||
Game.world.Remove(e);
|
||||
}
|
||||
|
||||
public void Tick()
|
||||
{
|
||||
if (--remainingTicks == 0)
|
||||
Game.world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
public IEnumerable<Renderable> Render()
|
||||
{
|
||||
if (remainingTicks % 2 == 0)
|
||||
foreach (var r in target.Render())
|
||||
yield return r.WithPalette(PaletteType.Highlight);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,6 +82,7 @@
|
||||
<Compile Include="Combat.cs" />
|
||||
<Compile Include="Effects\Corpse.cs" />
|
||||
<Compile Include="Effects\DelayedAction.cs" />
|
||||
<Compile Include="Effects\FlashTarget.cs" />
|
||||
<Compile Include="Effects\MoveFlash.cs" />
|
||||
<Compile Include="Effects\RepairIndicator.cs" />
|
||||
<Compile Include="Effects\Smoke.cs" />
|
||||
|
||||
@@ -155,6 +155,9 @@ namespace OpenRa.Game.Traits
|
||||
{
|
||||
self.CancelActivity();
|
||||
QueueAttack(self, order);
|
||||
|
||||
if (self.Owner == Game.LocalPlayer)
|
||||
Game.world.AddFrameEndTask(w => w.Add(new FlashTarget(order.TargetActor)));
|
||||
}
|
||||
else
|
||||
target = null;
|
||||
|
||||
Reference in New Issue
Block a user