Game Development Reference
In-Depth Information
Then in Chapter 8, we added a basic but functional GUI (or front end ) to the game, allowing the
gamer to exit and restart the game. In achieving this, we explored the limitations of the native
GUI class and saw alternatives, such as the 4.3 sprite features. These allowed us to create a
multiresolution GUI that can position and size itself according to screen size. Finally, in Chapter 9
we added load-and-save game functionality to CMOD. With this, gamers can save and load game
sessions from XML files that persist between game sessions.
In sum, we've come a long way and seen C# applied practically in many ways. But, there's still so
much more to know and see. No single book could possibly cover it all. In fact, you could spend
weeks and months, and even years searching through topics and online tutorials, and still find new
concepts and ideas you'd never encountered before, because there's always more to learn. That's
the nature of the games industry—and probably every other industry, too! So the aim of this chapter,
which is about looking ahead, is comparatively modest. Its aim is to consider specific ways CMOD
could be reasonably improved or changed using only other concepts and techniques that we've not
covered in much detail already, to give you a feel for some additional features and ideas “out there”
in the field. So let's go!
Level Changing
As it stands, CMOD features only one level or scene. Consequently, the most obvious way in which
CMOD could be expanded is by adding more levels. The general idea would be that, on collecting all
cash power-ups in one level, the Player would progress to the next. And this process would repeat
for as many levels as there were in the game. Or maybe, you'd even create procedurally generated
levels (levels autogenerated at runtime), potentially allowing the game to progress indefinitely—or
until the gamer's patience expired! Whichever route you choose, you'll likely want the ability to change
levels in-game, moving from the Player from one level to the next. Thankfully, Unity makes this
task easy with the Application class. This class supports several level loading methods. The most
commonly used is LoadLevel , which looks like Listing 10-1.
Listing 10-1. Loading a Level Using Application.LoadLevel
Application.LoadLevel(1);
Note More information on the Application class can be found in the online Unity documentation at
https://docs.unity3d.com/Documentation/ScriptReference/Application.html .
Levels can be loaded either by number (ID) or by name (that is, the scene name, excluding the .scene
file extension). However, for LoadLevel to work as intended, all levels in the game must be included
in the levels list . This list can be accessed by choosing File Build Settings from the application
menu. From there, scene files can be dragged and dropped from the Project panel into the levels list.
You can also rearrange the order of scene files within the list by dragging and dropping items. Each
level is assigned a unique number or ID, shown in the right-hand column (see Figure 10-1 ). This ID
can be passed to the LoadLevel function to load the appropriate level.
 
 
Search WWH ::




Custom Search