Graphics Reference
In-Depth Information
2.1 Controllers and Managers
By specializing tasks to particular managers, it is possible to swap out other components
without affecting core functions, which, in turn, makes it easy to carry the same code from
game to game without having to rewrite it; from a first-person shooter to a racing game,
the same code may be used to store user session data, load levels, or control weapons. In
this topic, I use two terms to specify the type of class: controllers and managers .
2.1.1 Controllers
Controllers specialize in specific tasks such as helping scripts communicate with each
other, holding game-specific player information, or dealing with session data. For exam-
ple, at the center of all of the example games in this topic is a game controller script that
acts as a central location for game scripts to communicate. Each game has its own game
controller script acting like glue between the different components that otherwise have no
built-in method for communicating.
2.1.2 Managers
Managers are used in this topic as a term to represent a script that manages objects or data
specifically (dealing with players, audio, or other game elements in a similar way to how
a manager might manage staff in a company). For example, the GlobalBattleManager.cs
script is used to manage RaceController.cs instances to keep track of a deathmatch battle
in the example game Tank Battle . The manager script takes care of calculating the position
of the players on the scoreboard as well as informing players as to the game's current run-
ning state.
2.2 Building the Core Framework Scripts
There are several scripts in the Scripts/BASE folder that are intended to act as templates
for your own versions, or as classes to derive from, in your own games. In this section, we
will be looking at the scripts that make up the main framework.
Those core framework scripts in the BASE folder that will be covered in this chapter
are as follows:
2.2.1. BaseGameController.cs
2.2.2. SceneManager.cs
2.2.3. ExtendedCustomMonoBehavior.cs
2.2.4. BaseUserManager.cs
2.2.5. BasePlayerManager.cs
2.2.6. BaseInputController.cs
Search WWH ::




Custom Search