Game Development Reference
In-Depth Information
an NPC racer or the player. We determine this by checking the tag on the
object that entered as shown in the following code snippet:
condition_onEnter cOE =
(conditionAssciation as
condition_onEnter);
bool bIsPlayer =
(cOE).trackObj.CompareTag("Player");
bool bIsRacer =
(cOE).trackObj.CompareTag("Character");
21. If the object that entered is either a racer or player, insert the GameObject
reference into the listData condition wrapper. For safety, we only insert a
GameObject if it has not already been inserted into the list as shown in the
following code snippet:
listData rlist = (data as listData);
if (!rlist._a.Contains(coe.trackObj))
rlist._listData.Add(cOE.trackObj);
22. If a racer (not the player) entered the finish line, we set the racer to paused
so that it doesn't keep traversing its SplinePath as shown in the following
code snippet:
(if bIsRacer)
{
(cOE).trackObj.GetComponent<npcScript>().SetState(npcScript.npcState.pause);
23. Now that reponse_insert has been implemented, drag-and-drop the
listData script from the LevelLogicObj object to the data field on this
script. Then, drag-and-drop the instance of this script from LevelLogicObj
to the second response field of LevelLogicObj's DecisionMgr.
24. For the third condition, we need to create a new condition script called con-
dition_listFull . Go ahead and make a new script; change its base
class to npcCondition and add an instance to LevelLogicObj as usual.
25. Add a public variable to this script to track the number of entries that will rep-
resent full, and a public npcCondition called data , as shown in the fol-
lowing code snippet:
Search WWH ::




Custom Search