In this section, we are going to make our ScenesManager script recognize levels 2 and 3 from our scenes folder (Assets/Scenes). We will then add these levels to the game loop. Also, we will be adding a game timer for each level. When the timer reaches its limit, we can then trigger the player leaving the level with an animation that will play out. Lastly, we will add a few common methods to move the game onto the next level.
Let's start by opening the ScenesManager script (Assets/Resources/Script/Scenesmanager.cs) and adding some global variables to assist with what we were talking about. Follow these steps:
- At the top of the ScenesManager script, add the following global variables:
float gameTimer = 0;
float[] endLevelTimer = {30,30,45};
int currentSceneNumber = 0;
bool gameEnding = false;
The gameTimer variable timer will be used as our current counter to time how long the level...