level now should end correctly every time

This commit is contained in:
Rendo 2025-07-22 17:55:18 +05:00
commit 394b07db60
7 changed files with 53 additions and 25 deletions

View file

@ -13,6 +13,7 @@ public partial class LevelRunner : Node
private bool rewardGiven = false;
public float waveHealth = 0;
public float waveHealthMax = 0;
public int aliveZombies = 0;
public List<RuntimeZombieData> zombies = [];
[Export] private MoneyReward defaultReward;
[Export] private RowSpawner rowSpawner;
@ -128,12 +129,14 @@ public partial class LevelRunner : Node
if (waveIndex == resource.waves.Count - 1)
{
aliveZombies+=1;
zombie.HasBeenKilled += OnLastZombieKilled;
}
}
private void OnLastZombieKilled(RuntimeZombieData who)
{
if (waveHealth > 0) return;
aliveZombies -= 1;
if (aliveZombies > 0) return;
SpawnReward(who.GlobalPosition);
}