Game Development Reference
In-Depth Information
[System.Serializable]
public class response_changeState :
npcResponse {
3. This class will have two members, an npcState enumeration and a refer-
ence to the npcScript class. When fired, the script will set the state on the
npcScript reference to the value set in the local enumeration:
public npcScript.npcState newstate;
public npcScript npc;
4. As with classes that derive from npcCondition , we need to override the
abstract method provided in the base class. Instead of eval() , we will over-
ride dispatch() :
public override bool dispatch()
5. If this response class has an NPC reference, it will set the value of newState
on to NPC through the SetState() setter method that npcScript imple-
ments:
if (npc != null)
{
npc.SetState (newstate);
rval = true;
}
return rval;
Congratulations! We now have all the pieces to finally develop an npcDecisionMgr
class that can tell the NPC to patrol or face the play when close enough. While it's
true that we invest resources into developing a generic decision handling system,
let's see how this pays dividends when implementing the logic in the editor.
Search WWH ::




Custom Search