Book Image

Creating E-Learning Games with Unity

By : David Horachek
Book Image

Creating E-Learning Games with Unity

By: David Horachek

Overview of this book

Table of Contents (17 chapters)
Creating E-Learning Games with Unity
About the Author
About the Reviewers

Creating the AddScore condition

The AddScore condition will be used by levelLogicObj to track the points earned in this mission. Once the requisite number of points have been earned, this script will return true. This, in turn, will dispatch the response of showing the Success pop up via the ShowLevel3Results response script. Writing this script requires the following steps to be performed:

  1. Create a new script named condition_scoreAdded. Change the base class from MonoBehavior to npcCondition as done with the other condition classes.

  2. Add an instance of this script to LevelLogicObj.

  3. Drag-and-drop this script instance into the second slot of decisionMgr on LevelLogicObj as shown in the following code:

  4. Inside the script, add an int datatype for scoreAdded; this is the number of points necessary for the condition to return true:

    public int scoreAdd;
  5. Add an npcCondition called initialScore. Drag-and-drop the instance of this script from setupLevel3 (remember the object that first stored the score on...