fix destroyed walls count too high
This commit is contained in:
parent
3d69f592f6
commit
6045de0c7d
|
@ -76,11 +76,8 @@ internal sealed class CollideBullets(
|
|||
for (var y = pixel.Y - i; y <= pixel.Y + i; y++)
|
||||
{
|
||||
var offsetPixel = new PixelPosition(x, y);
|
||||
if (options.Value.DestructibleWalls)
|
||||
{
|
||||
map.Current.DestroyWallAt(offsetPixel);
|
||||
if (options.Value.DestructibleWalls && map.Current.TryDestroyWallAt(offsetPixel))
|
||||
owner.Scores.WallsDestroyed++;
|
||||
}
|
||||
|
||||
TryHitTankAt(offsetPixel.ToFloatPosition(), owner);
|
||||
}
|
||||
|
|
|
@ -104,5 +104,11 @@ internal sealed class Map(string name, bool[,] walls)
|
|||
return false;
|
||||
}
|
||||
|
||||
public void DestroyWallAt(PixelPosition pixel) => walls[pixel.X, pixel.Y] = false;
|
||||
public bool TryDestroyWallAt(PixelPosition pixel)
|
||||
{
|
||||
var result = walls[pixel.X, pixel.Y];
|
||||
if (result)
|
||||
walls[pixel.X, pixel.Y] = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue