Game win notification
As a final finishing touch, we'll tell the player that they have successfully won the game when the fire has been lit, as this is the goal of our game.
Open the PlayerCollisions script in the Scripts folder of the Project panel, and scroll to the bottom. The last function in the script is lightFire()
and into this we'll add some more commands before its terminating right curly brace. Move down a couple of lines from the current last line:
Destroy(GameObject.Find("matchGUI"));
And place in the following commands:
TextHints.textOn=true; TextHints.message = "You Lit the Fire, you'll survive, well done!"; yield new WaitForSeconds(5); Application.LoadLevel("Menu");
Here we're switching back on our TextHints
GUI from earlier, and sending the message "You Lit the Fireā¦
" as the string of text to display on screen. We then use a yield
command to halt the script for 5
seconds, and then load the Menu
level of the game, so that the player may play again.
Now press the Play button,...