moved gps into mod

This commit is contained in:
Chris Forbes
2010-01-29 19:58:11 +13:00
parent 206e4fb558
commit 938c45fc87
6 changed files with 13 additions and 12 deletions

View File

@@ -0,0 +1,34 @@
using System.Collections.Generic;
using OpenRa.Effects;
using OpenRa.Graphics;
using OpenRa.Traits;
namespace OpenRa.Mods.RA.Effects
{
class GpsSatellite : IEffect
{
readonly float heightPerTick = 10;
float2 offset;
Animation anim = new Animation("sputnik");
public GpsSatellite(float2 offset)
{
this.offset = offset;
anim.PlayRepeating("idle");
}
public void Tick( World world )
{
anim.Tick();
offset.Y -= heightPerTick;
if (offset.Y < 0)
world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,offset, PaletteType.Gold);
}
}
}

View File

@@ -0,0 +1,38 @@
using System.Collections.Generic;
using OpenRa.Effects;
using OpenRa.Graphics;
using OpenRa.Traits;
namespace OpenRa.Mods.RA.Effects
{
class SatelliteLaunch : IEffect
{
int frame = 0;
Actor a;
Animation doors = new Animation("atek");
float2 doorOffset = new float2(-4,0);
public SatelliteLaunch(Actor a)
{
this.a = a;
doors.PlayThen("active",
() => a.World.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick( World world )
{
doors.Tick();
if (++frame == 19)
{
world.AddFrameEndTask(w => w.Add(new GpsSatellite(a.CenterLocation - .5f * doors.Image.size + doorOffset)));
}
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(doors.Image,
a.CenterLocation - .5f * doors.Image.size + doorOffset, PaletteType.Gold);
}
}
}

View File

@@ -1,6 +1,6 @@
using OpenRa.Traits.Activities;
using OpenRa.Mods.RA.Activities;
using OpenRa.Traits;
using OpenRa.Mods.RA.Activities;
using OpenRa.Traits.Activities;
namespace OpenRa.Mods.RA
{

View File

@@ -0,0 +1,43 @@
using System.Linq;
using OpenRa.Effects;
using OpenRa.Mods.RA.Effects;
using OpenRa.Traits;
namespace OpenRa.Mods.RA
{
class GpsPowerInfo : SupportPowerInfo
{
public readonly int RevealDelay = 0;
public override object Create(Actor self) { return new GpsPower(self, this); }
}
class GpsPower : SupportPower
{
public GpsPower(Actor self, GpsPowerInfo info) : base(self, info) { }
protected override void OnFinishCharging()
{
var launchSite = Owner.World.Actors
.FirstOrDefault(a => a.Owner == Owner && a.traits.Contains<GpsLaunchSite>());
if (launchSite == null)
return;
Owner.World.AddFrameEndTask(w =>
{
Sound.PlayToPlayer(Owner, "satlnch1.aud");
w.Add(new SatelliteLaunch(launchSite));
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
() => Owner.Shroud.HasGPS = true));
});
FinishActivate();
}
}
// tag trait to identify the building
class GpsLaunchSiteInfo : StatelessTraitInfo<GpsLaunchSite> { }
class GpsLaunchSite { }
}

View File

@@ -53,9 +53,12 @@
<Compile Include="Activities\Steal.cs" />
<Compile Include="C4Demolition.cs" />
<Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
<Compile Include="Effects\InvulnEffect.cs" />
<Compile Include="Effects\Parachute.cs" />
<Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="EngineerCapture.cs" />
<Compile Include="GpsPower.cs" />
<Compile Include="InfiltrateForSonarPulse.cs" />
<Compile Include="IronCurtainable.cs" />
<Compile Include="IronCurtainPower.cs" />