move backend to subfolder

This commit is contained in:
Vinzenz Schroeter 2024-04-21 12:38:03 +02:00
parent d4d1f2f981
commit 8d09663eff
80 changed files with 98 additions and 88 deletions

View file

@ -0,0 +1,30 @@
namespace TanksServer.GameLogic;
internal sealed class CollectPowerUp(
MapEntityManager entityManager
) : ITickStep
{
public Task TickAsync(TimeSpan delta)
{
entityManager.RemoveWhere(TryCollect);
return Task.CompletedTask;
}
private bool TryCollect(PowerUp obj)
{
var position = obj.Position;
foreach (var tank in entityManager.Tanks)
{
var (topLeft, bottomRight) = tank.Bounds;
if (position.X < topLeft.X || position.X > bottomRight.X ||
position.Y < topLeft.Y || position.Y > bottomRight.Y)
continue;
// this works because now the tank overlaps the power up
tank.ExplosiveBullets += 10;
return true;
}
return false;
}
}