From 5dbc70da02c9a8dbe1f287bd28b3b9c141712f80 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 1 Nov 2009 17:56:05 +1300 Subject: [PATCH] water splashes --- OpenRa.Game/Bullet.cs | 15 ++++++++++++--- OpenRa.Game/Explosion.cs | 9 +++------ OpenRa.Game/Game.cs | 7 +++++++ sequences.xml | 6 ++++++ units.ini | 2 ++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/OpenRa.Game/Bullet.cs b/OpenRa.Game/Bullet.cs index 282bdb3d6f..a0e25ee072 100644 --- a/OpenRa.Game/Bullet.cs +++ b/OpenRa.Game/Bullet.cs @@ -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(); diff --git a/OpenRa.Game/Explosion.cs b/OpenRa.Game/Explosion.cs index dd954f7999..3e8fe08c78 100644 --- a/OpenRa.Game/Explosion.cs +++ b/OpenRa.Game/Explosion.cs @@ -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(); } diff --git a/OpenRa.Game/Game.cs b/OpenRa.Game/Game.cs index ff12aad0b4..f8e262107e 100644 --- a/OpenRa.Game/Game.cs +++ b/OpenRa.Game/Game.cs @@ -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 FindUnits(float2 a, float2 b) { var min = float2.Min(a, b); diff --git a/sequences.xml b/sequences.xml index a6988ecffe..6cfee2f777 100644 --- a/sequences.xml +++ b/sequences.xml @@ -463,7 +463,13 @@ + + + + + + diff --git a/units.ini b/units.ini index 117c9a1450..78311be792 100755 --- a/units.ini +++ b/units.ini @@ -475,3 +475,5 @@ Nuke [HE] ImpactSound=kaboom25 +WaterImpactSound=splash9 +