[MUSIC] Hi, everyone. I'm Jeremy Gibson Bond and here we are. Your final solution to your final challenge for the stealth game. So let's take a look at it. The first thing that I want to look at is the game manager script. Now, you can see here that I just have the level names set in the inspector here in a list. And of course, those levels need to be part of the build, so you have to bring them in to build settings along with the persistent scene. And of course, the persistent scene needs to be the zeroth scene. So it's the first one that loads. Jumping into the game manager and code, you can see that I have the two events that I talked about in the problem set. LEVEL_START_EVENT and LEVEL_END_EVENT. Those are going to be really important when we're dealing with the minimap later. The game manager has four states, idle, pre-level, level and post level. Pre-level and post level are when the level advance panel is showing. There are also the times that we additively and subtractively managing our scenes. In start, you can see that the first thing I do is set the state to post level and then I fade into end level and I pass load level in as my callback method. This is the method that's going to get called as soon as the fade in happens for the level advanced final, that starts it in and it pops into things as level one. When this callback happens, load level is called without a parameter. So you can see here that it then calls the overload with a parameter, with a parameter of -1 which causes it to use the level that is the current level now. Otherwise, you can use it to jump ahead in levels if you wanted to create a menu of levels or something like that. We're not using that in this game. At the end of load level, we have a coder team that we call load scene and set active and we pass in the name of the scene that we want to additively load. You can see here that if there are more the one scene currently in the scene manager, the scene count is greater than 1, then we first unload the scene asynchronously which is the active scene and we do this based on the build index. Then we take the interacting player and we move her way outside the scene, so that there are no collisions between that character and anything we're loading into the scene. Next, we load a scene asynchronously with the additive mode set. And again, we wait until it has finished loading until we continue to the next line and that's the strength, of course, of the co-routine. Once we've loaded the scene, we set it to be the active scene through this newly loaded scene temporary variable. And making it the active scene allows us to later, when we load the next scene on line 67 unload it by getting the active scene, getting the build index of that scene and then telling the scene manager to unload it. So that's how we manage which scene is active and which one we want to unload between the persistent scene that we never want to unload, and the level that we do. After everything's loaded, we set the state to pre-level and then we call FadeOutToBeginLevel on the LevelAdvancePanel with a callback of StartLevel. Here's the start level method. The first thing we do is set the alarm to be false, so that we turn off any alarms that are blaring. Then we find the player start and move the player to that position and rotation and we reset the self-player camera to its far position, so that it's set up relative to the player. That does get rid of the sort of panning across the scene thing that we were doing before, but that's totally fine. Then we set the state to be in the level and we call the level start event for anything that is registered for that event. To continue with the game manager, I'll just point out here that reload level loads the same level again and the way it does this is it subtracts one from the current level number and then it ends the level which increase one. So if you're on level two and you failed, it will go back to level one for a split second and then advance to level two and load up level two. And so you can see at the end of reload level, it calls end level which is the standard way that we end a level and advance to the next level and then load it. And then there, of course is the LEVEL_END_EVENT that we call and then at the end of the game manuscript are some static methods and properties that make it easier for other scripts to interact with it. Now, let's take a look at the minimap. Now, you recall a mini map has two scripts on the camera. First, there's the minimap camera script which scales the camera to encompass the entire level. Then there's also the minimap manager which is what adds the minimap blips to the map and has them follow around the player, and the enemies, and such. Because these are two separate scripts, we don't want to entangle them with each other by having one call the other or manage the other or something like that. So what I did instead was setup those events on the game manager, so that each of them is notified by the game manager. And frankly, does not matter which one goes first. There's no race condition between the two. First, we'll take a look at the minimap camera script and you'll see that all I've done to modify this is I've removed the initial FillCameraWithLevel call and I've replaced it with gamemanager.event+=FillCameraWithLevel. Which means anytime level start event is called by the game manager, FillCameraWithLevel will be called and it'll zoom the camera properly. The minimap manager was slightly more complex, but really not much. I just added both the LEVEL_START-EVENT and the LEVEL_END_EVENT. So AssignBlips is called the beginning of the level and it puts a blip on everything like the enemies, and the player. And then DestroyActiveBlips is called at the end of the level and that removes those blips, so that we don't get the instance where the blip is still there. But the objects it's tracking has been unloaded. And so we're going to know what reference exception and the only remaining things are the level goal script which is just trigger enter that tells the game manager that player is gotten to the goal, and then a tiny change to the enemy nav script to allow it to know when it has caught the player, and actually notify the game manager to restart the level. So that's it for the solution to your final challenge for the stealth game. I hope you had fun with this one and I hope you can see how a lot of the elements that you did here can be used in lots of other projects that you make. Up next, we've got some videos for you. These are topics that didn't necessarily fit into the two games that we created, but we're still important for you to know for the exam. So I hope to see you in those videos. Take care. [MUSIC]