Game Development Reference
In-Depth Information
Figure 10-41. Level hopping
Comment out the print statements in the Start function and the Update
function, and save the script.
9.
10.
Save the StartMenu scene.
The most crucial task now is to determine what has to be retained while the player is accessing
the main menu. The number one question is whether or not the game has begun. If the Gnomatic
Garden Defender remains in the staging area, you could either do a clean restart or just save the
location and orientation of the Gnomatic Garden Defender.
The stork fly-bys uncover a different problem. Once a coroutine is invoked, it can't be canceled and
then restarted at a particular point in its duration. The StartReproducing function, however, does
have several yields controlling the drop sequence. If the drop hasn't started yet, you can trigger the
fly-by again. If it has, you can simply trigger the 3D zombie-bunny drop in the scene when the game
resumes without worrying about the 2D warning system—e.g., the fly-by.
Let's begin with the simpler tasks. The Gnomatic Garden Defender's transform must be stored
right before the level change to the Main Menu, but only if the current level is a garden level. The
SensorDoor script is in charge of starting the actual game play.
To manage the data exchange, you will be tracking the currently loaded level and the state of the
game itself. You will be creating a new variable named gameState . State 0 will mean you have not yet
entered a garden level. You can only be in a menu at this point. State 1 means you have entered a
garden level, but the game is not yet underway. You are in, or have been in, the staging area or have
gone into one of the menus via the main menu. State 2 means the game has started. At this point,
you could be anywhere other than the start menu.
 
Search WWH ::




Custom Search