Survival mode ready
This commit is contained in:
parent
0fff33d196
commit
7614b12076
50 changed files with 586 additions and 81 deletions
|
|
@ -9,11 +9,18 @@ public partial class ZombieSequencer : Node2D
|
|||
public static ZombieSequencer Instance { get; private set; }
|
||||
private Queue<string> queue = [];
|
||||
private RandomNumberGenerator rng = new();
|
||||
private bool turbo = false;
|
||||
|
||||
[Export] private Timer spawnTimer;
|
||||
[Export] private Timer waveTimer;
|
||||
|
||||
private double startSpawnTime;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
rng.Randomize();
|
||||
Instance = this;
|
||||
startSpawnTime = spawnTimer.WaitTime;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -44,7 +51,8 @@ public partial class ZombieSequencer : Node2D
|
|||
|
||||
foreach (int lane in list)
|
||||
{
|
||||
Spawn(queue.Dequeue(), lane);
|
||||
if (queue.Count > 0)
|
||||
Spawn(queue.Dequeue(), lane);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -53,11 +61,30 @@ public partial class ZombieSequencer : Node2D
|
|||
RuntimeZombieData zombie = GameRegistry.GetZombieByName(id).scene.Instantiate<RuntimeZombieData>();
|
||||
PoolContainer.Instance.Zombies.AddChild(zombie);
|
||||
|
||||
zombie.GlobalPosition = new Vector2(GlobalPosition.X, Utility.RightFieldBoundary.Y - (lane-1) * Utility.TileHeight);
|
||||
zombie.GlobalPosition = new Vector2(GlobalPosition.X, Utility.RightFieldBoundary.Y - (lane - 1) * Utility.TileHeight);
|
||||
}
|
||||
|
||||
public void Add(string id)
|
||||
{
|
||||
queue.Enqueue(id);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (turbo == false && queue.Count > waveTimer.WaitTime / startSpawnTime * 5.0)
|
||||
{
|
||||
spawnTimer.WaitTime = waveTimer.WaitTime / queue.Count;
|
||||
turbo = true;
|
||||
}
|
||||
else if(turbo && queue.Count == 0)
|
||||
{
|
||||
spawnTimer.WaitTime = startSpawnTime;
|
||||
turbo = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void DebugClearQueue()
|
||||
{
|
||||
queue.Clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue