You win the game when all enemies are destroyed before the level time has run out
Create a function to check if there are any enemies left after spawning has stopped
Before we implement UI, just print a message "You won!"
Connect the enemies tree_exited signal to the enemy_defeated function
This ensures our function is run anytime an enemy signals that it has exited the scene tree
add a new CanvasLayer node as a child
Rename it to VictoryLayer
Add a ColorRect node as a child of
In the Anchor Presets menu
In the Color property of the ColorRect
Set the Alpha channel to 150
The Victory Layer should be hidden to start
If the game is one it can be made visible
Create an export variable of type CanvasLayer
Select the EnemyPath Node
Load the VictoryLayer node
Now in the enemy_path script
Add a line to make the victory layer visible
Building the Victory Screen
Start by saving the VictoryLayer as its own scene
Open the VictoryLayer scene
Make the VictoryLayer visible again
Add a CenterContainer as a child
Set the Anchor Preset to Full Rect
Add a PanelContainer as a child
Add a VBoxContainer as a child
Then add a Label node as a child of
Add a new LabelSettings resource
Expand it and increase font size to 96px
Change the Horizontal Alignment to Center
Now add an HBoxContainer as a child of
Then add a Button as a child of HBoxContainer
Change the text property of the button to
Rename the Button to RetryButton
Duplicate the RetryButton
Attach a script to the VictoryLayer node
Connect the pressed signal for the retry button
Connect the pressed signal for the quit button
Remember to set the CanvasLayer to invisible
Since we saved VictoryLayer as its own scene
We need to go back to BaseLevel
and reassign VictoryLayer to variable