#76 smudge
This commit is contained in:
@@ -72,20 +72,36 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
Game.world.AddFrameEndTask(w =>
|
Game.world.AddFrameEndTask(w =>
|
||||||
{
|
{
|
||||||
w.Remove(this);
|
w.Remove(this);
|
||||||
|
|
||||||
var isWater = Game.IsCellBuildable(
|
var targetTile = ((1f / Game.CellSize) * Dest.ToFloat2()).ToInt2();
|
||||||
((1f / Game.CellSize) * Dest.ToFloat2()).ToInt2(), UnitMovementType.Float);
|
|
||||||
|
var isWater = Game.IsWater(targetTile);
|
||||||
|
var hitWater = Game.IsCellBuildable(targetTile, UnitMovementType.Float);
|
||||||
|
|
||||||
if (Warhead.Explosion != 0)
|
if (Warhead.Explosion != 0)
|
||||||
w.Add(new Explosion(VisualDest, Warhead.Explosion, isWater));
|
w.Add(new Explosion(VisualDest, Warhead.Explosion, hitWater));
|
||||||
|
|
||||||
var impact = Warhead.ImpactSound;
|
var impact = Warhead.ImpactSound;
|
||||||
if (isWater && Warhead.WaterImpactSound != null)
|
if (hitWater && Warhead.WaterImpactSound != null)
|
||||||
impact = Warhead.WaterImpactSound;
|
impact = Warhead.WaterImpactSound;
|
||||||
|
|
||||||
if (impact != null)
|
if (impact != null)
|
||||||
Game.PlaySound(impact+ ".aud", false);
|
Game.PlaySound(impact+ ".aud", false);
|
||||||
|
|
||||||
|
if (!isWater)
|
||||||
|
switch( Warhead.Explosion ) /* todo: push the scorch/crater behavior into data */
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
|
case 5:
|
||||||
|
Smudge.AddSmudge(true, targetTile.X, targetTile.Y);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3:
|
||||||
|
case 6:
|
||||||
|
Smudge.AddSmudge(false, targetTile.X, targetTile.Y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var maxSpread = GetMaximumSpread();
|
var maxSpread = GetMaximumSpread();
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ namespace OpenRa.Game.Graphics
|
|||||||
for (int i = 0; i < overlaySpriteNames.Length; i++)
|
for (int i = 0; i < overlaySpriteNames.Length; i++)
|
||||||
overlaySprites[i] = SpriteSheetBuilder.LoadAllSprites(overlaySpriteNames[i], ".shp", ".tem", ".sno");
|
overlaySprites[i] = SpriteSheetBuilder.LoadAllSprites(overlaySpriteNames[i], ".shp", ".tem", ".sno");
|
||||||
|
|
||||||
/* todo: add the rest of the smudge sprites */
|
smudgeSprites = new[] { "bib3", "bib2", "sc1", "sc2", "sc3", "sc4", "sc5", "sc6",
|
||||||
smudgeSprites = new[] { "bib3", "bib2" }.SelectMany(
|
"cr1", "cr2", "cr3", "cr4", "cr5", "cr6", }.SelectMany(
|
||||||
f => SpriteSheetBuilder.LoadAllSprites(f, ".shp", ".tem", ".sno")).ToArray();
|
f => SpriteSheetBuilder.LoadAllSprites(f, ".shp", ".tem", ".sno")).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,6 +91,7 @@
|
|||||||
<Compile Include="PathSearch.cs" />
|
<Compile Include="PathSearch.cs" />
|
||||||
<Compile Include="ProductionItem.cs" />
|
<Compile Include="ProductionItem.cs" />
|
||||||
<Compile Include="ReplayOrderSource.cs" />
|
<Compile Include="ReplayOrderSource.cs" />
|
||||||
|
<Compile Include="Smudge.cs" />
|
||||||
<Compile Include="Support\Stopwatch.cs" />
|
<Compile Include="Support\Stopwatch.cs" />
|
||||||
<Compile Include="Support\PerfHistory.cs" />
|
<Compile Include="Support\PerfHistory.cs" />
|
||||||
<Compile Include="Traits\AcceptsOre.cs" />
|
<Compile Include="Traits\AcceptsOre.cs" />
|
||||||
|
|||||||
33
OpenRa.Game/Smudge.cs
Normal file
33
OpenRa.Game/Smudge.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace OpenRa.Game
|
||||||
|
{
|
||||||
|
static class Smudge
|
||||||
|
{
|
||||||
|
const int firstScorch = 11;
|
||||||
|
const int firstCrater = 17;
|
||||||
|
const int framesPerCrater = 5;
|
||||||
|
|
||||||
|
public static void AddSmudge(bool isCrater, int x, int y)
|
||||||
|
{
|
||||||
|
var smudge = Rules.Map.MapTiles[x, y].smudge;
|
||||||
|
if (smudge == 0)
|
||||||
|
Rules.Map.MapTiles[x, y].smudge = (byte) (isCrater
|
||||||
|
? (firstCrater + framesPerCrater * ChooseSmudge())
|
||||||
|
: (firstScorch + ChooseSmudge()));
|
||||||
|
|
||||||
|
if (smudge < firstCrater || !isCrater) return; /* bib or scorch; don't change */
|
||||||
|
|
||||||
|
/* deepen the crater */
|
||||||
|
var amount = (smudge - firstCrater) % framesPerCrater;
|
||||||
|
if (amount < framesPerCrater - 1)
|
||||||
|
Rules.Map.MapTiles[x, y].smudge++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int lastSmudge = 0;
|
||||||
|
static int ChooseSmudge() { lastSmudge = (lastSmudge + 1) % 6; return lastSmudge; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user