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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the NPC decision system


The NPCs in our e-learning game will need to be able to interact with the player and the world in addition to following a user-defined path. While the path-following code was easily encapsulated in one file, we will see that a general purpose solution to the first problem requires a more intricate design.

Our solution will be modeled around and function similarly to a question-and-answer system. A number of classes will be required for implementation:

  • npcCondition: This is the base class for a question that the NPCs logic will ask about the player or the world.

  • npcResponse: This is the base class for a response that the NPCs logic will invoke if a condition is found to be true.

  • npcInteraction: This container class will house the association of a condition with a response. It will be responsible for testing if the condition is true (whatever the condition may be) and for invoking the appropriate response when that happens.

  • npcDecisionMgr: This class is the...