Game Development Reference
In-Depth Information
Creating the CorrectResponse Prefabs
The
CorrectResponse
Prefabs are the pop ups that will be instantiated from the
npcDialog
(quiz cards) for
LEVEL3
. Create these according to the following steps:
1. Copy and paste the
popup_QuizSuccessQuestion
Prefab into a new
folder in the folder named
Chapter 9
.
2. Create 50 unique
CorrectResponse
cards—one for each state/NPC dialog
interaction.
3. We do not need to pass
missionToken
into
missionMgr
when this pop up
destructs itself, so ensure that there is no
missionToken
attached (it will do
no harm, but it is redundant).
4. Modify
PopupButtonScript.cs
and add an
AwardPoints
action. Make
sure that when the button is clicked on each of these Prefabs, 500 points are
awarded to the user. When the button is clicked, we simply find the
play-
er
class and the
playerData
component, and then add these values to the
score member variable as shown in the following code. Don't forget to add the
action to the enumeration at the top of the file:
// inside Dispatch()
case(popupAction.AwardPoints):
{
GameObject p = GameObject.Find
("Player1");
if (p)
{
PlayerData pd =
p.GetComponent<PlayerData>();
if (pd)
{
pd.AddScore (r.data.id);
}
}
break;
}