Game Development Reference
In-Depth Information
3. The upper-left corner of the texture, relative to the center of the screen, is
assigned using the following code:
(((ScreenWidth/2.0f) - (textureWidth/2)),
((ScreenHeight/2.0f) - (textureHeight/
2.0f)))
Creating the SetupMissionOne script
This class is used on level startup to configure the world with a random selection of
flags for gameplay. This class picks five flags at random and five locations at ran-
dom. It instances those five flags at those random locations. It also configures the
two missions that this level will use to achieve the first learning objective. It is created
by performing the following steps:
1. This script will require six individual lists to accomplish its task. Three of them
for picking five flags from 50 potential options and three for picking five loca-
tions from a set of 10 options.
2. flagPrefabs holds all 50 flag Prefabs. This is populated once at design
time in the editor as shown in the following code:
public List<GameObject> flagPrefabs;
3. flagPrefabsBackup is a copy of the previous list. This occurs once when
the game is run. The backup will be used to restore the flagPrefabs list if
the mission is restarted as shown in the following code:
private List<GameObject>
flagPrefabsBackup;
4. FlagInstances is the list of five unique, selected flagPrefabs . This list
is populated from the flagPrefab list by choosing an index at random, re-
Search WWH ::




Custom Search