add magazine system (cannot reload currently)

This commit is contained in:
Vinzenz Schroeter 2024-04-29 16:39:37 +02:00
parent 4e605d556c
commit 9ccb7c8df8
8 changed files with 86 additions and 32 deletions

View file

@ -21,7 +21,11 @@ internal sealed class CollectPowerUp(
continue;
// now the tank overlaps the power up by at least 0.5 tiles
tank.ExplosiveBullets += 10;
tank.Magazine = tank.Magazine with
{
UsedBullets = 0,
Type = MagazineType.Explosive
};
tank.Owner.Scores.PowerUpsCollected++;
return true;
}

View file

@ -21,15 +21,18 @@ internal sealed class ShootFromTanks(
{
if (!tank.Owner.Controls.Shoot)
return;
if (tank.Magazine.Empty)
return;
if (tank.NextShotAfter >= DateTime.Now)
return;
tank.NextShotAfter = DateTime.Now.AddMilliseconds(_config.ShootDelayMs);
tank.Magazine = tank.Magazine with
{
UsedBullets = (byte)(tank.Magazine.UsedBullets + 1)
};
var explosive = tank.ExplosiveBullets > 0;
if (explosive)
tank.ExplosiveBullets--;
var explosive = tank.Magazine.Type.HasFlag(MagazineType.Explosive);
tank.Owner.Scores.ShotsFired++;
entityManager.SpawnBullet(tank.Owner, tank.Position, tank.Orientation / 16d, explosive);
}