# LevelManager

## Level Manager Overview

In the code below, the Level Manager is responsible for controlling the Mini\_Game Level Logic, this includes determining when to change levels and what gameObjects are impacted when the level changes. The LevelManager Custom Script is attached to the LevelManager game object in the Mini-Game scene and provides Finite State Machine logic to determine the current level and state of dependent gameObjects within the Mini-game.

### Inter-Dependent Game Objects

Game objects that are inter-dependent with the LevelManager are:

1. Splash Screen (optional) - UI Panel with StartMiniGame Button - is hidden when StartGameButton is clicked.
2. Background Images - changed with each level-change
3. Spawners: minimum of 1 per gameLevel: Spawner\_L1-L3: start spawning when splash screen start-button is clicked, spawn different prefabs depending on the current level
4. UI Elements - Level and Score UI displays must be updated to reflect the current Level and the current Score value.
5. PlayerController - this GameObject will sense collisions with PickUps, this will change the score and the level
6. GameData - create a new variable levelScore, and a new property: LevelScore, these are changed in GameData when the score is updated.

### UnityEvents - Event-Driven Game

The following list of events drive the game's logic.  The Events invoke the methods listed.  These methods must be configured to be added as Listeners for the events listed.  [See Logic Diagram ](https://kdoore.gitbook.io/cs2335/master_v2/mini-game_proj3/level-manager-in-class/level-manager-logic-diagram)

* GameData.onPlayerDataUpdate --> MiniGameOver( )
* LevelManager: Timer complete --> ReloadMiniGame( )&#x20;
* PlayerController.onPlayerDied --> MiniGameOver( )
* GameData.onPlayerDataUpdate --> NextLevel( )&#x20;
* PlayerController.onPlayerReachExit -->NextLevel( )
* LevelManager: Timer complete --> ReloadMiniGame( )&#x20;
