spyplane works

This commit is contained in:
Chris Forbes
2010-01-24 14:53:18 +13:00
parent 74af815f24
commit da40ab449e
7 changed files with 70 additions and 10 deletions

View File

@@ -160,6 +160,7 @@
<Compile Include="Traits\Activities\Idle.cs" />
<Compile Include="Traits\Activities\Land.cs" />
<Compile Include="Traits\Activities\Rearm.cs" />
<Compile Include="Traits\Activities\RemoveSelf.cs" />
<Compile Include="Traits\Activities\Repair.cs" />
<Compile Include="Traits\Activities\ReturnToBase.cs" />
<Compile Include="Traits\Activities\Sell.cs" />

View File

@@ -7,6 +7,8 @@ namespace OpenRa.Traits.Activities
{
public class CallFunc : IActivity
{
public CallFunc(Action a) { this.a = a; }
Action a;
public IActivity NextActivity { get; set; }

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace OpenRa.Traits.Activities
{
class RemoveSelf : IActivity
{
bool isCanceled;
public IActivity NextActivity { get; set; }
public IActivity Tick(Actor self)
{
if (isCanceled) return NextActivity;
self.World.AddFrameEndTask(w => w.Remove(self));
return null;
}
public void Cancel(Actor self) { isCanceled = true; NextActivity = null; }
}
}

View File

@@ -2,11 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Traits.Activities;
namespace OpenRa.Traits
{
class SpyPlanePowerInfo : SupportPowerInfo
{
public readonly int Range = 10;
public override object Create(Actor self) { return new SpyPlanePower(self,this); }
}
@@ -21,6 +23,18 @@ namespace OpenRa.Traits
Sound.Play("slcttgt1.aud");
}
static int2 ChooseRandomEdgeCell(World w)
{
var isX = Game.SharedRandom.Next(2) == 0;
var edge = Game.SharedRandom.Next(2) == 0;
return new int2(
isX ? Game.SharedRandom.Next(w.Map.XOffset, w.Map.XOffset + w.Map.Width)
: (edge ? w.Map.XOffset : w.Map.XOffset + w.Map.Width),
!isX ? Game.SharedRandom.Next(w.Map.YOffset, w.Map.YOffset + w.Map.Height)
: (edge ? w.Map.YOffset : w.Map.YOffset + w.Map.Height));
}
public void ResolveOrder(Actor self, Order order)
{
if (order.OrderString == "SpyPlane")
@@ -30,14 +44,17 @@ namespace OpenRa.Traits
if (order.Player == Owner.World.LocalPlayer)
Game.controller.CancelInputMode();
// todo: pick a cell p1 on the edge of the map; get the cell p2 at the other end of the line
// through that p1 & the target location;
var enterCell = ChooseRandomEdgeCell(self.World);
var exitCell = ChooseRandomEdgeCell(self.World);
// todo: spawn a SpyPlane at p1 with activities:
// -- fly to target point
// -- take picture
// -- fly to p2
// -- leave the world
var plane = self.World.CreateActor("U2", enterCell, self.Owner);
plane.CancelActivity();
plane.QueueActivity(new Fly(Util.CenterOfCell(order.TargetLocation)));
plane.QueueActivity(new CallFunc(
() => Owner.Shroud.Explore(Owner.World, order.TargetLocation,
(Info as SpyPlanePowerInfo).Range)));
plane.QueueActivity(new Fly(Util.CenterOfCell(exitCell)));
plane.QueueActivity(new RemoveSelf());
}
}

View File

@@ -781,6 +781,19 @@ HIND:
Ammo: 12
IronCurtainable:
U2:
Inherits: ^Plane
Unit:
HP: 2000
Armor: heavy
ROT: 7
Sight: 0
Speed: 40
Plane:
RenderUnit:
WithShadow:
IronCurtainable:
IRON:
Inherits: ^Building
Buildable:

View File

@@ -379,14 +379,14 @@
<sequence name="deploy" start="59" length="9" x="12" y="12" />
<sequence name="sell" start="68" length="12" x="12" y="12" />
<sequence name="default-minimap" start="80" length="1" />
<sequence name="ability" start="82" length="8" x="12" y="12"/>
<sequence name="ability" start="82" length="8" x="12" y="12" />
<sequence name="nuke" start="90" length="7" x="12" y="12" />
<sequence name="chrono-select" start="97" length="8" x="12" y="12" />
<sequence name="chrono-target" start="105" length="8" x="12" y="12" />
<sequence name="enter" start="113" length="3" x="12" y="12" />
<sequence name="c4" start="116" length="3" x="12" y="12" />
<sequence name="sell-blocked" start="119" length="1" x="12" y="12" />
<sequence name="repair-blocked" start="120" length="1" x="12" y="12"/>
<sequence name="repair-blocked" start="120" length="1" x="12" y="12" />
<sequence name="c4-minimap" start="121" length="3" />
<sequence name="scroll-blocked" start="124" length="8" />
<sequence name="attackmove-minimap" start="134" length="8" />
@@ -1037,4 +1037,7 @@
<unit name="fb2">
<sequence name="idle" start="0" length="4" />
</unit>
<unit name="u2">
<sequence name="idle" start="0" length="16" />
</unit>
</sequences>

View File

@@ -164,6 +164,7 @@ YAK
TRAN
HELI
HIND
U2
; TODO:
; U2 (spyplane)
; BADR (paratrooper/paradrop plane)
@@ -206,7 +207,8 @@ PrimaryOffset=-5,0,0,2
SecondaryOffset=5,0,0,2
InitialFacing=20
LongDesc=Helicopter Gunship with Chainguns.\n Strong vs Infantry, Light Vehicles.\n Weak vs Tanks
[U2]
Traits=Unit, Plane, RenderUnit, WithShadow, IronCurtainable