Setup the State Machine and add a Player GameObject

We're going to use a State Machine to control the game, so let's get some ideas of what we want:

  • The State classes for the State Machine
  • The BeginState class, which is a splash screen displayed when the game starts
  • The SetupState class, which provides game options
  • The PlayState classes, which are two levels of gameplay
  • The WonState classes, which show a graphic and proceed to the next level
  • The LostState classes, which show a graphic, and replay the level or restart the game
  • A Player GameObject
  • A script to hold game data

The following Scenes and States diagram shows three Scenes and nine States that we'll use to control game flow:

Setup the State Machine and add a Player GameObject

As you can see from this diagram, there are five more States and another Scene added to the project. We're almost starting fresh. Much of the code that was added in Chapter 8 has been removed, and some new code has been added for this chapter.

Note

During this initial testing of the State Machine setup, the States will temporarily use the Space bar and Return keys for switching. Also, Debug information is displayed in the Console to show the active State.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.152.139