water splashes

This commit is contained in:
Chris Forbes
2009-11-01 17:56:05 +13:00
parent 4dd54eb1e3
commit 5dbc70da02
5 changed files with 30 additions and 9 deletions

View File

@@ -67,10 +67,19 @@ namespace OpenRa.Game
Game.world.AddFrameEndTask(w =>
{
w.Remove(this);
w.Add(new Explosion(VisualDest, Warhead.Explosion));
if (Warhead.ImpactSound != null)
Game.PlaySound(Warhead.ImpactSound + ".aud", false);
var isWater = Game.IsCellBuildable(
((1f / Game.CellSize) * Dest.ToFloat2()).ToInt2(), UnitMovementType.Float);
if (Warhead.Explosion != 0)
w.Add(new Explosion(VisualDest, Warhead.Explosion, isWater));
var impact = Warhead.ImpactSound;
if (isWater && Warhead.WaterImpactSound != null)
impact = Warhead.WaterImpactSound;
if (impact != null)
Game.PlaySound(impact+ ".aud", false);
});
var maxSpread = GetMaximumSpread();

View File

@@ -13,16 +13,13 @@ namespace OpenRa.Game
Animation anim;
int2 pos;
public Explosion(int2 pixelPos, int style)
public Explosion(int2 pixelPos, int style, bool isWater)
{
this.pos = pixelPos;
var variantSuffix = isWater ? "w" : "";
anim = new Animation("explosion");
if (style != 0)
anim.PlayThen(style.ToString(),
anim.PlayThen(style.ToString() + variantSuffix,
() => Game.world.AddFrameEndTask(w => w.Remove(this)));
else
Game.world.AddFrameEndTask(w => w.Remove(this));
}
public void Tick() { anim.Tick(); }

View File

@@ -165,6 +165,13 @@ namespace OpenRa.Game
worldRenderer.terrainRenderer.tileSet.GetWalkability( map.MapTiles[ a.X, a.Y ] ) ) < double.PositiveInfinity;
}
public static bool IsWater(int2 a)
{
return map.IsInMap(a.X, a.Y) &&
TerrainCosts.Cost(UnitMovementType.Float,
worldRenderer.terrainRenderer.tileSet.GetWalkability(map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
}
static IEnumerable<Actor> FindUnits(float2 a, float2 b)
{
var min = float2.Min(a, b);

View File

@@ -463,7 +463,13 @@
<sequence name="3" start="0" length="14" src="napalm2" />
<sequence name="4" start="0" length="14" src="veh-hit3" />
<sequence name="5" start="0" length="22" src="veh-hit2" />
<sequence name="6w" start="0" length="27" src="atomsfx" />
<sequence name="1w" start="0" length="10" src="h2o_exp3" />
<sequence name="5w" start="0" length="10" src="h2o_exp1" />
<sequence name="3w" start="0" length="14" src="napalm2" />
<sequence name="6" start="0" length="27" src="atomsfx" />
<sequence name="4w" start="0" length="10" src="h2o_exp2" />
<sequence name="2w" start="0" length="10" src="h2o_exp3" />
</unit>
<unit name="lst">
<sequence name="idle" start="0" length="1" />

View File

@@ -475,3 +475,5 @@ Nuke
[HE]
ImpactSound=kaboom25
WaterImpactSound=splash9