diff --git a/OpenRa.Game/Bullet.cs b/OpenRa.Game/Bullet.cs index 0e3e255a06..79610653c8 100644 --- a/OpenRa.Game/Bullet.cs +++ b/OpenRa.Game/Bullet.cs @@ -59,6 +59,7 @@ namespace OpenRa.Game { game.world.AddFrameEndTask(w => w.Remove(this)); game.PlaySound("kaboom25.aud", false); + game.world.AddFrameEndTask(w => w.Add(new Explosion(Dest, game))); } } diff --git a/OpenRa.Game/Explosion.cs b/OpenRa.Game/Explosion.cs new file mode 100644 index 0000000000..63a1eaf2dc --- /dev/null +++ b/OpenRa.Game/Explosion.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using OpenRa.Game.Graphics; +using IjwFramework.Types; +using OpenRa.Game.GameRules; + +namespace OpenRa.Game +{ + class Explosion : IEffect + { + Animation anim; + int2 pos; + + public Explosion(int2 pixelPos, Game g) + { + this.pos = pixelPos; + + anim = new Animation("veh-hit3"); + anim.PlayThen("idle", () => g.world.AddFrameEndTask(w => w.Remove(this))); + } + + public void Tick(Game g) { anim.Tick(); } + + public IEnumerable> Render() + { + yield return Pair.New(anim.Image, pos.ToFloat2() - 0.5f * anim.Image.size); + } + + public Player Owner { get { return null; } } + } +} diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index c32ed17a2f..a2b284aa20 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -56,7 +56,7 @@ namespace OpenRa.Game.Graphics foreach (Actor a in game.world.Actors) DrawSpriteList(a.Owner, rect, a.Render()); - foreach (IEffect e in game.world.Bullets) + foreach (IEffect e in game.world.Effects) DrawSpriteList(e.Owner, rect, e.Render()); uiOverlay.Draw(); diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 57004ee3a0..cb4bef35b9 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -78,6 +78,7 @@ + diff --git a/OpenRa.Game/World.cs b/OpenRa.Game/World.cs index 83533b21ee..05ffa41292 100644 --- a/OpenRa.Game/World.cs +++ b/OpenRa.Game/World.cs @@ -8,7 +8,7 @@ namespace OpenRa.Game class World { List actors = new List(); - List bullets = new List(); + List effects = new List(); List> frameEndActions = new List>(); readonly Game game; int lastTime = Environment.TickCount; @@ -19,8 +19,8 @@ namespace OpenRa.Game public void Add(Actor a) { actors.Add(a); ActorAdded(a); } public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); } - public void Add(Bullet b) { bullets.Add(b); } - public void Remove(Bullet b) { bullets.Remove(b); } + public void Add(IEffect b) { effects.Add(b); } + public void Remove(IEffect b) { effects.Remove(b); } public void AddFrameEndTask( Action a ) { frameEndActions.Add( a ); } @@ -42,7 +42,7 @@ namespace OpenRa.Game foreach( var a in actors ) a.Tick(game); - foreach (var b in bullets) + foreach (var b in effects) b.Tick(game); Renderer.waterFrame += 0.00125f * timestep; @@ -53,6 +53,6 @@ namespace OpenRa.Game } public IEnumerable Actors { get { return actors; } } - public IEnumerable Bullets { get { return bullets; } } + public IEnumerable Effects { get { return effects; } } } } diff --git a/sequences.xml b/sequences.xml index 75922cd451..713e2819e5 100644 --- a/sequences.xml +++ b/sequences.xml @@ -341,5 +341,9 @@ + + + +