LoadLevel, StartLevel Logic
Last updated
Last updated
The image below shows how the LevelManager FSM logic within the NextLevel( ) method manages all tasks required for switching levels. This diagram represents one section of the logic on the LevelManager Diagram, LevelManager FMS with SubStates
As events cause NextLevel to be executed, within the NextLevel( ) method, the first code executed is that the variable: curLevel is changed to the next corresponding state as shown in the NextLevel table in the image below. Then either a StartLevel( ) or LoadLevel( ) method is executed, depending on whether transitioning to Level1, or to Level2 or Level3. The subsequent diagrams show the logic exectued within each of these methods.
The LoadLevel( ) methods have logic to stop spawning, timer, and to hide the player. Then the LoadLevel( ) method has logic to show the StartPanel and configure the StartButton's text , AddListener for the corresponding StartLevel( ) method.
The StartLevel( ) method are exectued when the StartButton has been clicked. It has logic for hiding the StartPanel and gameObjectLayers for the previous level. The StartLevel( ) method has logic for showing current level gameObjectLayers, resetting the player's position back to the spawnPoint, and setting the player to be active. It also sets the LevelText to display the currentLevel. Finally, the StartLevel( ) method starts the Spawner for the currentLevel, and starts the timer.