官术网_书友最值得收藏!

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 the OnCloseEnough 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:

Understanding the base scripts
主站蜘蛛池模板: 建宁县| 腾冲县| 化州市| 吴川市| 蒲城县| 通河县| 五大连池市| 遵义县| 建水县| 新晃| 岳阳县| 金乡县| 敦化市| 合川市| 古蔺县| 蕉岭县| 海盐县| 广西| 贵州省| 罗田县| 张家港市| 香港| 高青县| 安龙县| 宁津县| 龙井市| 巢湖市| 邯郸市| 长武县| 社旗县| 栾城县| 佛山市| 罗江县| 杭锦后旗| 沛县| 金山区| 思南县| 武川县| 监利县| 化隆| 乐安县|