Expanding our ScenesManager script
In this section, we are going to make our ScenesManager
script recognize levels 2 and 3 from our scenes
folder (Assets/Scene
). 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/Script/Scenesmanager.cs
) and adding some variables to assist with what we were talking about. Follow these steps:
- At the top of the
ScenesManager
script, add the following 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 has left until it...