this is the last development blog, the project is done everything in my task plan has been made and functions correctly.
Trees and Rocks
The last of the work on the environment, adding decorations. The final product is the result of every type of tree and rock I used in testing placed throughout the environment.
There are two menus. The Start menu, which contains the game modes and the Quit menu which has yes or no buttons when the user tries to quit the game.
this menu contains several UI elements, all of which are text boxes, some have button scripts attached
The title text box Forest Walk and instructions are not buttons. Day, Night, Morning, Fast Time start the game witch different settings. Quit opens the quit menu.
the quit menu is three text boxes placed over a grey and transparent image. Yes and No are buttons.
Yes quits the game, No closes the menu. In the finished game it looks like this:
Scripting the Menus
This script is much longer and more complicated than rotate and find checkpoint. MenuScript contains everything done by the menus, accessing the menus and button clicks in the menus.
In this part of the code everything im going to be using is made a public variable. This includes both menus, the Canvas objects and the buttons that are placed on them. There are also GameObjects for the player, a camera and the time of day system.
The two float variables will be needed later.
This is the start method it is called when the script is first enabled, in this case when the game is run. Here the variables are set to get there components so the variables can be used in other methods.
Quit menu is disabled at the start, it should only be seen when quit is clicked. Player is disabled as it would start the game if it was active. A camera is used to display the environment behind the menus.
This is what happens when the quit button is clicked. The quit menu is enabled and the other buttons are disables, this prevents the quit menu from being open after the game has started.
No press is the opposite of quit press, it closes the quit menu and enables the start buttons.
These are three of the four start buttons and they are all the same except for the time variable. These methods disable the start menu, activate the player controls and disable the menu camera. the time of day script is accessed through the public variable and set by 24 hour clock, a number between 0 and 24.
this starts the game at a specific time.
Fast Time is similar to the other three game start buttons except it also changes the day length to 60 seconds, resulting in a very fast moving skybox.
Exit is attached to the yes button and closes the game. That is all the buttons covered but we still need a way to access the menu.
When the escape key is pressed the opposite of game start occurs. The player is disabled and the start menu is displayed through the menu camera.
The Cursor settings allow the mouse to be used while the menu is open.
To get this script working in unity I created a empty object called game manager. This object does nothing but hold scripts that are used elsewhere.
The game objects and UI elements I need have been dragged from the hierarchy and dropped into the public variables.
To set methods to buttons game manager is dragged into the on click commands for a button, then the required method is selected.
The completed game can be downloaded Here.
the link for the games files is Here.