move upgrades to tank, serialize objects directly

This commit is contained in:
Vinzenz Schroeter 2024-05-08 00:29:33 +02:00
parent b1df817ece
commit 827b3a9330
16 changed files with 135 additions and 180 deletions

View file

@ -18,25 +18,9 @@ internal sealed class SpawnPowerUp(
if (Random.Shared.NextDouble() > _spawnChance * delta.TotalSeconds)
return ValueTask.CompletedTask;
var type = Random.Shared.Next(4) == 0
? PowerUpType.MagazineSize
: PowerUpType.MagazineType;
MagazineType? magazineType = type switch
{
PowerUpType.MagazineType => Random.Shared.Next(0, 3) switch
{
0 => MagazineType.Fast,
1 => MagazineType.Explosive,
2 => MagazineType.Smart,
_ => throw new UnreachableException()
},
_ => null
};
var type = (PowerUpType)Random.Shared.Next((int)Enum.GetValues<PowerUpType>().Max());
var position = emptyTileFinder.ChooseEmptyTile().GetCenter().ToFloatPosition();
entityManager.SpawnPowerUp(position, type, magazineType);
entityManager.SpawnPowerUp(position, type);
return ValueTask.CompletedTask;
}
}