destructible walls
This commit is contained in:
parent
a0a0762f84
commit
dec571d8c1
1 changed files with 73 additions and 56 deletions
|
|
@ -4,10 +4,17 @@ internal sealed class CollideBulletsWithMap(BulletManager bullets, MapService ma
|
|||
{
|
||||
public Task TickAsync()
|
||||
{
|
||||
bullets.RemoveWhere(BulletHitsWall);
|
||||
bullets.RemoveWhere(TryHitAndDestroyWall);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private bool BulletHitsWall(Bullet bullet) =>
|
||||
map.Current.IsWall(bullet.Position.ToPixelPosition());
|
||||
private bool TryHitAndDestroyWall(Bullet bullet)
|
||||
{
|
||||
var pixel = bullet.Position.ToPixelPosition();
|
||||
if (!map.Current.IsWall(pixel))
|
||||
return false;
|
||||
|
||||
map.Current.DestroyWallAt(pixel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue