Foolproof

This commit is contained in:
Rendo 2025-07-21 14:39:30 +05:00
commit d06893a639

View file

@ -10,6 +10,7 @@ public partial class LevelRunner : Node
private AdventureLevelResource resource;
private int waveIndex = -1;
private bool hugeWaveApproaching = false;
private bool rewardGiven = false;
public float waveHealth = 0;
public float waveHealthMax = 0;
public List<RuntimeZombieData> zombies = [];
@ -41,6 +42,10 @@ public partial class LevelRunner : Node
hugeWaveApproaching = true;
EmitSignal(SignalName.HugeWaveApproachingCallback);
}
if (rewardGiven == false && waveIndex == resource.waves.Count && PoolContainer.Instance.Zombies.GetChildCount() == 0)
{
SpawnReward(GetViewport().GetCamera2D().GlobalPosition);
}
}
@ -71,7 +76,7 @@ public partial class LevelRunner : Node
}
if (waveIndex == 0)
{
AudioSequencer.Play("fl_wave",firstWaveSound);
AudioSequencer.Play("fl_wave", firstWaveSound);
}
waveTimer.WaitTime = resource.waves[waveIndex].customWaveDelay > 0 ? resource.waves[waveIndex].customWaveDelay : resource.standardWaveDelay;
@ -130,6 +135,11 @@ public partial class LevelRunner : Node
{
if (waveHealth > 0) return;
SpawnReward(who.GlobalPosition);
}
private void SpawnReward(Vector2 where)
{
rewardGiven = true;
RuntimeLevelData.Instance.SetLevelState(RuntimeLevelData.LevelStates.Win);
DroppableItem reward;
@ -154,7 +164,7 @@ public partial class LevelRunner : Node
{
rewardParent.AddChild(reward);
reward.GlobalPosition = who.GlobalPosition + Vector2.Up * FieldParams.TileHeight * 0.5f;
reward.GlobalPosition = where + Vector2.Up * FieldParams.TileHeight * 0.5f;
var dropmover = new DropMover();
reward.AddChild(dropmover);