Game Development Reference
In-Depth Information
The
response_ShowRaceResultsPopup
class will use the
GameMan-
ager
reference, and based on the data condition and result, it will enable
either
passPopup
or
retryPopup
.
32. Edit
response_ShowRaceResultsPopup
so that its base is
npcRe-
sponse
.
33. Drag-and-drop the
listData
component from
LevelLogicObj
to the data
field of this script.
34. Drag-and-drop the
GameMgr
script from the GameObject to the
Gm
field
of this script. Recall that this GameObject lives as a child of the
_global
GameObject.
35. Drag-and-drop the
player1
reference from beneath
_global
to the player
reference in this response script.
36. Drag-and-drop the
popup_Level2Finish
pop up from beneath
MainCamera
(which is beneath
_global
) to the
pass
reference field of this script.
37. Drag-and-drop the
popup_Level2Repeat
pop up from beneath
MainCam-
era
to the
fail
reference field of this script. At this point your component
should look somewhat like the following screenshot:
38. Inside this script, the
dispatch()
method does the brunt of the work. We
compute if the player is first by checking if the
player
reference is equal to
the first cell in the
listData
component's list array, as shown in the follow-
ing code snippet:
bool playerIsFirst = (data as
listData)._listData[0] == player;
39. If the player is first, and we can locate the
missionMgr
script from the game,
we point the camera looking up (to make sure the pop up is shown with a
nice effect) as shown in the following code snippet: