max power up count
This commit is contained in:
parent
d02100f9a3
commit
2a94a47a96
|
@ -5,4 +5,6 @@ internal sealed class GameRules
|
||||||
public bool DestructibleWalls { get; set; } = true;
|
public bool DestructibleWalls { get; set; } = true;
|
||||||
|
|
||||||
public double PowerUpSpawnChance { get; set; }
|
public double PowerUpSpawnChance { get; set; }
|
||||||
|
|
||||||
|
public int MaxPowerUpCount { get; set; } = int.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,9 +6,12 @@ internal sealed class SpawnPowerUp(
|
||||||
) : ITickStep
|
) : ITickStep
|
||||||
{
|
{
|
||||||
private readonly double _spawnChance = options.Value.PowerUpSpawnChance;
|
private readonly double _spawnChance = options.Value.PowerUpSpawnChance;
|
||||||
|
private readonly int _maxCount = options.Value.MaxPowerUpCount;
|
||||||
|
|
||||||
public Task TickAsync(TimeSpan delta)
|
public Task TickAsync(TimeSpan delta)
|
||||||
{
|
{
|
||||||
|
if (entityManager.PowerUps.Count() >= _maxCount)
|
||||||
|
return Task.CompletedTask;
|
||||||
if (Random.Shared.NextDouble() > _spawnChance * delta.TotalSeconds)
|
if (Random.Shared.NextDouble() > _spawnChance * delta.TotalSeconds)
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,8 @@
|
||||||
},
|
},
|
||||||
"GameRules": {
|
"GameRules": {
|
||||||
"DestructibleWalls": true,
|
"DestructibleWalls": true,
|
||||||
"PowerUpSpawnChance": 0.1
|
"PowerUpSpawnChance": 0.1,
|
||||||
|
"MaxPowerUpCount": 15
|
||||||
},
|
},
|
||||||
"Players": {
|
"Players": {
|
||||||
"SpawnDelayMs": 3000,
|
"SpawnDelayMs": 3000,
|
||||||
|
|
Loading…
Reference in a new issue