spy behavior

This commit is contained in:
Chris Forbes
2010-01-15 18:02:05 +13:00
parent 342d6c26d2
commit 4e7c604764
9 changed files with 67 additions and 13 deletions

View File

@@ -166,6 +166,7 @@
<Compile Include="Graphics\OverlayRenderer.cs" />
<Compile Include="Graphics\WorldRenderer.cs" />
<Compile Include="Traits\Activities\Idle.cs" />
<Compile Include="Traits\Activities\Infiltrate.cs" />
<Compile Include="Traits\Activities\Land.cs" />
<Compile Include="Traits\Activities\Rearm.cs" />
<Compile Include="Traits\Activities\Repair.cs" />
@@ -244,6 +245,7 @@
<Compile Include="Traits\Repairable.cs" />
<Compile Include="Traits\Reservable.cs" />
<Compile Include="Traits\Selectable.cs" />
<Compile Include="Traits\Spy.cs" />
<Compile Include="Traits\SquishByTank.cs" />
<Compile Include="Traits\Plane.cs" />
<Compile Include="Traits\ProductionQueue.cs" />

View File

@@ -35,7 +35,6 @@ namespace OpenRa.Game.Traits.Activities
}
// the engineer is sacrificed.
self.Health = 0;
Game.world.AddFrameEndTask(w => w.Remove(self));
return NextActivity;

View File

@@ -0,0 +1,25 @@

namespace OpenRa.Game.Traits.Activities
{
class Infiltrate : IActivity
{
Actor target;
public Infiltrate(Actor target) { this.target = target; }
public IActivity NextActivity { get; set; }
public IActivity Tick(Actor self)
{
if (target == null || target.IsDead) return NextActivity;
if (target.Owner == self.Owner) return NextActivity;
foreach (var t in target.traits.WithInterface<IAcceptSpy>())
t.OnInfiltrate(target, self);
Game.world.AddFrameEndTask(w => w.Remove(self));
return NextActivity;
}
public void Cancel(Actor self) { target = null; NextActivity = null; }
}
}

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OpenRa.Game.Traits.Activities
{
class Steal : IActivity
@@ -20,6 +16,8 @@ namespace OpenRa.Game.Traits.Activities
foreach (var t in target.traits.WithInterface<IAcceptThief>())
t.OnSteal(target, self);
Game.world.AddFrameEndTask(w => w.Remove(self));
return NextActivity;
}

32
OpenRa.Game/Traits/Spy.cs Normal file
View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
class SpyInfo : StatelessTraitInfo<Spy> { }
class Spy : IIssueOrder, IResolveOrder
{
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button != MouseButton.Right) return null;
if (underCursor != null) return null;
if (underCursor.traits.WithInterface<IAcceptSpy>().Any()) return null;
return new Order("Infiltrate", self, underCursor, int2.Zero, null);
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "Infiltrate")
{
self.CancelActivity();
self.QueueActivity(new Move(order.TargetActor, 1));
self.QueueActivity(new Infiltrate(order.TargetActor));
}
}
}
}

View File

@@ -20,10 +20,6 @@ namespace OpenRa.Game.Traits
if (Game.LocalPlayer == thief.Owner)
Sound.Play("credit1.aud");
// the thief is sacrificed.
thief.Health = 0;
Game.world.AddFrameEndTask(w => w.Remove(thief));
}
public IEnumerable<PipType> GetPips(Actor self)
@@ -33,7 +29,6 @@ namespace OpenRa.Game.Traits
return Graphics.Util.MakeArray( numPips,
i => (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / numPips)
? PipType.Yellow : PipType.Transparent );
}
}
}

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using System.Drawing;
using IjwFramework.Types;
using OpenRa.Game.GameRules;
using OpenRa.Game.Graphics;
using IjwFramework.Types;
namespace OpenRa.Game.Traits
{
@@ -21,7 +21,9 @@ namespace OpenRa.Game.Traits
interface INotifyDamage { void Damaged(Actor self, AttackInfo e); }
interface INotifyBuildComplete { void BuildingComplete (Actor self); }
interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
interface IAcceptThief { void OnSteal(Actor self, Actor thief); }
interface IAcceptSpy { void OnInfiltrate(Actor self, Actor spy); }
interface IProducer
{

View File

@@ -2130,6 +2130,7 @@ SPY:
Sight: 5
Speed: 4
TakeCover:
Spy:
-AutoTarget:
THF:

View File

@@ -586,7 +586,7 @@ SelectionSize=12,17,0,-9
[SPY]
Description=Spy
Voice=SpyVoice
Traits=Unit, Mobile, RenderInfantry, TakeCover, SquishByTank, Passenger
Traits=Unit, Mobile, RenderInfantry, TakeCover, SquishByTank, Passenger, Spy
LongDesc=Infiltrates enemy structures to gather \nintelligence. Exact effect depends on the \nbuilding infiltrated.\n Strong vs Nothing\n Weak vs Everything\n Special Ability: Disguised
SelectionSize=12,17,0,-9
[THF]