- Creating ELearning Games with Unity
- David Horachek
- 582字
- 2021-07-16 12:22:51
Understanding the base scripts
The interactive Object
class is the base script that enables a player in our game to have meaningful gameplay interactions. To meet the design needs of our game, this script provides an interface with which the game designer can specify how the player will interact with an object as it is picked up. In addition to this, it also permits subtle rotation on the object for a nice effect. The CustomGameObj
and ObjectInteraction
helper classes are used by the object
class to define the specific nature of the interactions and how the object behaves in the inventory when collected.
The MissionMgr
class is the system that tracks the user's progress through the game and rewards him or her on achieving success. When a user interacts with an interactive object, MissionToken
attached to it (if any) is collected and tracked by MissionMgr
. The MissionMgr
class has a template of all missions, the tokens that each mission is composed of, and the reward that should be given when a mission is satisfied. When the MissionMgr
class determines that a mission is complete and that all of the tokens from that mission have been collected, it gives a reward to the user.
Lastly, InventoryMgr
is the system that handles the display of the interactive objects that have been collected. If an object is permitted to be collected, it will be added to the inventory according to its CustomGameObj
and then displayed in the inventory at the bottom of the screen.
The following list outlines the classes that we will develop in this chapter:
CustomGameObj
: This class contains the basic data about an object in our game. It holds the object's name and type. This information will be used when we interact with this object.InteractiveObj
: This class controls the behavior of an object that the user will physically interact with in the game world. It makes the object rotate and also detects when the player gets close enough to it to start an interaction.InventoryMgr
: This class tracks which interactive objects the user has collected. It will also display them in the inventory at the bottom of the screen. Objects can be either unique or can accumulate based on their type.ObjectInteraction
: This class describes how an interactive object should behave and what will be the nature of interaction when the user interacts with it. To start, we will use theOnCloseEnough
event to dispatch a collect and put into inventory interaction.SimpleLifespanScript
: This class is used by the reward objects that are spawned when a mission is complete. This makes them disappear after a predetermined amount of time.MissionToken
: This class represents an abstract logical component of a mission or an objective. These will be collected in ways similar to inventory objects.Mission
: This class represents a collection of mission tokens. When the player obtains all of the tokens, the learning objective will be deemed satisfied.MissionMgr
: This class stores all of the missions currently accessible to the user. It will validate each mission to determine if the player has acquired all of the tokens. If so, it will handle the task of giving the user an appropriate reward for their performance.
The CustomGameObj
and InteractiveObj
systems will interact with one another because our game's collecting mechanism is based on how the user primarily acquires and interacts with mission objectives. Once we have this core mechanism coded, with a couple of simple collection missions, we will illustrate how it works:

- Introduction to DevOps with Kubernetes
- Hands-On Machine Learning on Google Cloud Platform
- 教父母學會上網(wǎng)
- Cloud Analytics with Microsoft Azure
- Learning Social Media Analytics with R
- Windows程序設計與架構
- 計算機系統(tǒng)結構
- Learning Azure Cosmos DB
- Grome Terrain Modeling with Ogre3D,UDK,and Unity3D
- 未來學徒:讀懂人工智能飛馳時代
- 系統(tǒng)安裝、維護與數(shù)據(jù)備份技巧
- ARM嵌入式系統(tǒng)開發(fā)完全入門與主流實踐
- CPLD/FPGA技術應用
- Oracle Blockchain Quick Start Guide
- 我的IT世界