GameDev : the Game Manager!
Here we are, and now we need to talk about the Game Manager.
Normally, in the Games, there is always a Game Manager who manages every single aspect of the Game.
He is a bit of the “director” of our game.
It acts as like UI Manager, but it manage the FLOW of our Game.
We starting to create it
And we need a script
Look at this
Internally, Unity knows about Game Manager, and set it with a GEAR ICON.
Open the script.
Inside, we delete for now Start and Update, and we create a bool for Game Over. Why?
Because it is the Game Manager and it has to KNOW when the Game is Over.
Now we need a method to set bool to true when the Game is Over
After this, from HERE we create Update() method, and check
So what should we do?
A simple thing : we cut the code inside UI Manager
and paste it in Game Manager
We have errors, don’t worry about it.
First, ALT+ENTER on SceneMagaer and add
_restartText.enabled == true
_isGameOver == true
Now we have set the right method in the right place.
We have already added the scene to the Build Setting, so the last thing to do is call the Game Over method.
Go to UI Manager and create a reference to the Game Manager
And in the GameOverSequence() call
If we test it
And everything is fine, but the logic is much better than before.