Game Development Reference
In-Depth Information
One last thing
Now that the player has left home, found some nasty goblins, and run away, it would be
nice if he didn't encounter anymore until he next leaves home.
So using the additional flag playerReturningHome we set in the GameState class,
we can set this in the battle manager when the player hits the button. We also then need to
unset this when the player leaves home again. So, update the OnGUI method in the battle
manager to set the playerReturningHome flag to true .
Then for the home scene, set the flag to false when the player leaves. This can be
achieved by either editing an existing script in the home scene or adding a new one to
change the flag state in the OnDestroy method mentioned earlier, or update the Nav-
igationManager script to set the flag when the player travels home. It is your choice.
In the sample code, I have added this to the NavigationManager script.
It is up to you and your game's design whether this is true for all battles or just for the
first; it all depends on the style of the game you are building.
Note
Don't forget to add the new Battle scene to the Build settings if you want to see it in the
final project!
Search WWH ::




Custom Search