Game Development Reference
In-Depth Information
3. The public variable status is an instance variable of the status enumerated
type in this class. We will use this initially to make sure that once a mission is
complete, MissionMgr no longer tries to validate it. This can be done with
the following code:
Public missionStatus status;
4. The specific elements that comprise a mission are the mission tokens that
the user puts in the tokens' collection. This is a collection of logical pieces
that comprises a complete objective in the game. This list will be compared
against the players' acquired tokens in MissionMgr , as shown in the follow-
ing code:
Public List<missionTokens> tokens;
5. The points and reward public variables are used to store the numerical
score and the in-game rewards that are given to the user when a mission is
completed. Note, GameObject reward could be used as a completion call-
back, in addition to a reference to a Prefab item for the user to pick up, as
shown in the following code:
public int points;
public GameObject reward;
6. The displayName public variable is used by the user in the Unity3D Editor
as a place for a helpful string to describe the mission's nature, as shown in
the following code:
public string displayName;
This class implements one method: the InvokeReward() method. This
function will spawn a new gameObject into the world that has been set in
the editor. Through this mechanism, the player can be rewarded with points,
a new object or objective can appear in the world, or any other outcome can
be encapsulated in a Unity Prefab object.
7. Once a mission has been validated and InvokeReward has been called,
the mission itself is disabled and its status is set to Completed , as shown in
the following code:
Search WWH ::




Custom Search