explosions
This commit is contained in:
@@ -59,6 +59,7 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
game.world.AddFrameEndTask(w => w.Remove(this));
|
game.world.AddFrameEndTask(w => w.Remove(this));
|
||||||
game.PlaySound("kaboom25.aud", false);
|
game.PlaySound("kaboom25.aud", false);
|
||||||
|
game.world.AddFrameEndTask(w => w.Add(new Explosion(Dest, game)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
33
OpenRa.Game/Explosion.cs
Normal file
33
OpenRa.Game/Explosion.cs
Normal file
@@ -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<Pair<Sprite, float2>> Render()
|
||||||
|
{
|
||||||
|
yield return Pair.New(anim.Image, pos.ToFloat2() - 0.5f * anim.Image.size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player Owner { get { return null; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,7 +56,7 @@ namespace OpenRa.Game.Graphics
|
|||||||
foreach (Actor a in game.world.Actors)
|
foreach (Actor a in game.world.Actors)
|
||||||
DrawSpriteList(a.Owner, rect, a.Render());
|
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());
|
DrawSpriteList(e.Owner, rect, e.Render());
|
||||||
|
|
||||||
uiOverlay.Draw();
|
uiOverlay.Draw();
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
<Compile Include="Bullet.cs" />
|
<Compile Include="Bullet.cs" />
|
||||||
<Compile Include="Controller.cs" />
|
<Compile Include="Controller.cs" />
|
||||||
<Compile Include="Cursor.cs" />
|
<Compile Include="Cursor.cs" />
|
||||||
|
<Compile Include="Explosion.cs" />
|
||||||
<Compile Include="GameRules\FieldLoader.cs" />
|
<Compile Include="GameRules\FieldLoader.cs" />
|
||||||
<Compile Include="GameRules\Footprint.cs" />
|
<Compile Include="GameRules\Footprint.cs" />
|
||||||
<Compile Include="GameRules\InfoLoader.cs" />
|
<Compile Include="GameRules\InfoLoader.cs" />
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace OpenRa.Game
|
|||||||
class World
|
class World
|
||||||
{
|
{
|
||||||
List<Actor> actors = new List<Actor>();
|
List<Actor> actors = new List<Actor>();
|
||||||
List<IEffect> bullets = new List<IEffect>();
|
List<IEffect> effects = new List<IEffect>();
|
||||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||||
readonly Game game;
|
readonly Game game;
|
||||||
int lastTime = Environment.TickCount;
|
int lastTime = Environment.TickCount;
|
||||||
@@ -19,8 +19,8 @@ namespace OpenRa.Game
|
|||||||
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
|
public void Add(Actor a) { actors.Add(a); ActorAdded(a); }
|
||||||
public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); }
|
public void Remove(Actor a) { actors.Remove(a); ActorRemoved(a); }
|
||||||
|
|
||||||
public void Add(Bullet b) { bullets.Add(b); }
|
public void Add(IEffect b) { effects.Add(b); }
|
||||||
public void Remove(Bullet b) { bullets.Remove(b); }
|
public void Remove(IEffect b) { effects.Remove(b); }
|
||||||
|
|
||||||
public void AddFrameEndTask( Action<World> a ) { frameEndActions.Add( a ); }
|
public void AddFrameEndTask( Action<World> a ) { frameEndActions.Add( a ); }
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
foreach( var a in actors )
|
foreach( var a in actors )
|
||||||
a.Tick(game);
|
a.Tick(game);
|
||||||
foreach (var b in bullets)
|
foreach (var b in effects)
|
||||||
b.Tick(game);
|
b.Tick(game);
|
||||||
|
|
||||||
Renderer.waterFrame += 0.00125f * timestep;
|
Renderer.waterFrame += 0.00125f * timestep;
|
||||||
@@ -53,6 +53,6 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Actor> Actors { get { return actors; } }
|
public IEnumerable<Actor> Actors { get { return actors; } }
|
||||||
public IEnumerable<IEffect> Bullets { get { return bullets; } }
|
public IEnumerable<IEffect> Effects { get { return effects; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -342,4 +342,8 @@
|
|||||||
<sequence name="idle" start="0" length="1" />
|
<sequence name="idle" start="0" length="1" />
|
||||||
</unit>
|
</unit>
|
||||||
|
|
||||||
|
<unit name="veh-hit3">
|
||||||
|
<sequence name="idle" start="0" length="*" />
|
||||||
|
</unit>
|
||||||
|
|
||||||
</sequences>
|
</sequences>
|
||||||
|
|||||||
Reference in New Issue
Block a user