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);
}
}
}