From 9b4959bbb2783fcc7d70120de8782038ad0426e4 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 8 Jan 2010 20:49:25 +1300 Subject: [PATCH] GPS satellite launch animation --- OpenRa.Game/Effects/GpsSatellite.cs | 33 +++++++++++++++++++++++ OpenRa.Game/Effects/SatelliteLaunch.cs | 37 ++++++++++++++++++++++++++ OpenRa.Game/OpenRa.Game.csproj | 2 ++ OpenRa.Game/Shroud.cs | 2 ++ OpenRa.Game/Traits/GpsSatellite.cs | 31 ++++++++++++--------- sequences.xml | 4 +++ 6 files changed, 97 insertions(+), 12 deletions(-) create mode 100644 OpenRa.Game/Effects/GpsSatellite.cs create mode 100644 OpenRa.Game/Effects/SatelliteLaunch.cs diff --git a/OpenRa.Game/Effects/GpsSatellite.cs b/OpenRa.Game/Effects/GpsSatellite.cs new file mode 100644 index 0000000000..55f58d3200 --- /dev/null +++ b/OpenRa.Game/Effects/GpsSatellite.cs @@ -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 Render() + { + yield return new Renderable(anim.Image,offset, PaletteType.Gold); + } + } +} diff --git a/OpenRa.Game/Effects/SatelliteLaunch.cs b/OpenRa.Game/Effects/SatelliteLaunch.cs new file mode 100644 index 0000000000..7cc0d36dca --- /dev/null +++ b/OpenRa.Game/Effects/SatelliteLaunch.cs @@ -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 Render() + { + yield return new Renderable(doors.Image, + a.CenterLocation - .5f * doors.Image.size + doorOffset, PaletteType.Gold); + } + } +} diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index c9317d181a..d78bfb97c2 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -83,10 +83,12 @@ + + diff --git a/OpenRa.Game/Shroud.cs b/OpenRa.Game/Shroud.cs index 400075390a..c6ec79a662 100644 --- a/OpenRa.Game/Shroud.cs +++ b/OpenRa.Game/Shroud.cs @@ -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) diff --git a/OpenRa.Game/Traits/GpsSatellite.cs b/OpenRa.Game/Traits/GpsSatellite.cs index 4cb62d968f..e71f8a3455 100644 --- a/OpenRa.Game/Traits/GpsSatellite.cs +++ b/OpenRa.Game/Traits/GpsSatellite.cs @@ -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; } } } diff --git a/sequences.xml b/sequences.xml index ba46bfa4a9..252a584725 100644 --- a/sequences.xml +++ b/sequences.xml @@ -94,6 +94,7 @@ + @@ -1030,4 +1031,7 @@ + + + \ No newline at end of file