Graphics Reference
In-Depth Information
There are several more scripts in the BASE folder of the example games than those
above; those scripts falling outside of the basic core framework will be dealt with on a
case-by-case basis throughout this topic, such as the AI scripts being dealt with in Chapter
9, where our AI system is covered in full, or in Chapter 8, where audio is explored.
2.2.1 BaseGameController.cs
The game controller acts as a hub for active game activity and a place where scripts that
may not be directly connected can send messages to each other. By routing scripts through
the game controller, they remain independent, and changing their behavior is a straight-
forward process of changing how messages are dealt with here rather than across multiple
scripts.
The core functions of the game controller are as follows:
1. Tracking game state
a. Storing the game state
b. Providing functions for changing the game state
c. Changing the game state based on calls to functions such as EndGame(),
StartGame(), or PauseGame()
2. Creating any player object(s)
3. Setting up the camera (any specifics such as telling the camera which player to
follow, etc.)
4. Communicating between session manager, user manager, and game actions (such
as score, etc.)
5. Handling any communications between scripts that we would like to keep as
standalone and not have to recode to talk directly to each other
Game controller is the core of gameplay, where overall game functions are defined
and dealt with and where the current game state is held. Keeping track of the game state is
important, as some elements will need to change their behavior based on this. If the game
is paused, for example, we may want to suspend all input, freeze game time, and show a
pop-up. When the game ends, we will need to disable player input and so on. Tracking
game states is the job of the game controller script.
A typical game may have several different core states, such as
1. Game running
2. Game paused
3. Loading
4. Game ended
Search WWH ::




Custom Search