Game Development Reference
In-Depth Information
=
ppm.Level3Repeat;
}
13. Congratulations! The initial setup for
_level3
is now complete. Let's turn
our attention to updating the
SetupMissionThree()
script. To begin, loc-
ate this script instance attached to the
setupLevel3
object. As with the pre-
vious two examples, this script is responsible for connecting the missing ref-
erences between pop ups that have global persistence and the GameObjects
that they refer to inside of specific level scene files—inside
_level3
in this
instance.
14. At the beginning of
Start()
, we search for the
Player
GameObject
(named either
Player
or
Player1
). If it is found, we store a reference to the
PlayerData
component for later use:
playerData pd = null;
GameObject go = GameObject.Find
("Player1");
if (go == null)
go = GameObject.Find ("Player");
if (go != null)
{
pd = go.GetComponent<playerData>();
}
15. Still in the
start
method, in the block where five random cards are chosen,
we check for the presence of the
PlayerData
component on the player. If
there is no data, it means we are playing this mission in standalone mode,
and so we should use five randomly chosen indices. If, however,
Player-
Data
has information contained therein, it means that we should use those
indices to populate our world to ensure the flag choices are consistent with
the previous level:
if (pd != null)
index = pd.flagChoices[k];
Congratulations! Mission 3 has been updated now to use the flag choices that were
randomly chosen in
LEVEL1
and reused in
LEVEL2
. With that, your e-learning game