GPS satellite launch animation

This commit is contained in:
Paul Chote
2010-01-08 20:49:25 +13:00
parent b332785d2e
commit 9b4959bbb2
6 changed files with 97 additions and 12 deletions

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.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()
{
anim.Tick();
offset.Y -= heightPerTick;
if (offset.Y < 0)
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public IEnumerable<Renderable> Render()
{
yield return new Renderable(anim.Image,offset, PaletteType.Gold);
}
}
}

View File

@@ -0,0 +1,37 @@
using System.Collections.Generic;
using OpenRa.Game.Graphics;
using OpenRa.Game.Traits;
namespace OpenRa.Game.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",
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
}
public void Tick()
{
doors.Tick();
if (++frame == 19)
{
Game.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

@@ -83,10 +83,12 @@
<Compile Include="Effects\Corpse.cs" />
<Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
<Compile Include="Effects\InvulnEffect.cs" />
<Compile Include="Effects\MoveFlash.cs" />
<Compile Include="Effects\PowerDownIndicator.cs" />
<Compile Include="Effects\RepairIndicator.cs" />
<Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="Effects\Smoke.cs" />
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Exts.cs" />

View File

@@ -32,6 +32,7 @@ namespace OpenRa.Game
for (int x = 0; x < 128; x++)
for (int y = 0; y < 128; y++)
explored[x, y] = true;
dirty = true;
}
public void HideAll()
@@ -39,6 +40,7 @@ namespace OpenRa.Game
for (int x = 0; x < 128; x++)
for (int y = 0; y < 128; y++)
explored[x, y] = false;
dirty = true;
}
Sprite ChooseShroud(int i, int j)

View File

@@ -1,22 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits
{
class GpsSatellite
class GpsSatellite : ITick
{
public GpsSatellite(Actor self)
{
// TODO: connect this to a special power that calls Activate();
Activate(self);
}
int frame = 0;
int revealTicks = 30 * 25; // 30 second delay between launch and reveal
bool fired = false;
public GpsSatellite(Actor self) {}
public void Tick(Actor self)
{
// HACK: Launch after 5 seconds
if (++frame == 150)
Activate(self);
if (fired && --revealTicks == 0)
{
self.Owner.Shroud.RevealAll();
}
}
public void Activate(Actor self)
{
// TODO: Launch satellite
self.Owner.Shroud.RevealAll();
Game.world.AddFrameEndTask(w => w.Add(new SatelliteLaunch(self)));
fired = true;
}
}
}

View File

@@ -94,6 +94,7 @@
<sequence name="idle" start="0" />
<sequence name="damaged-idle" start="1" />
<sequence name="make" start="0" length="*" src="atekmake" />
<sequence name="active" start="0" length="*" src="sputdoor" />
</unit>
<!-- soviet tech center -->
<unit name="stek">
@@ -1030,4 +1031,7 @@
<sequence name="left-normal" start="0" length="1" />
<sequence name="left-pressed" start="1" length="1" />
</unit>
<unit name="sputnik">
<sequence name="idle" start="0" length="4" />
</unit>
</sequences>