赞
踩
接续上一篇
UnityQuest Log Window (Old)
Thissection applies to the old Unity Quest Log Window.
TheUnity Quest Log Window component displays a quest log window using Unity GUI.You can use it as-is or use it as a template for implementing your own questlog window in another GUI system such as NGUI or Daikon Forge GUI. As-is, thiscomponent is already quite flexible because you can assign any GUI layout toits properties, allowing you to completely change its look and feel:
统一的任务日志窗口(旧)
本节适用于旧的统一的任务日志窗口。
统一的任务日志窗口组件显示使用Unity GUI任务日志窗口。你可以像或使用它作为另一个GUI系统如NGUI或萝卜伪造的GUI实现您自己的任务日志窗口模板使用它。例如,该组件已经相当灵活因为你可以指定任何界面布局的特性,让你彻底改变其外观和感觉:
TheDialogue System provides pre-built prefabs for some Unity Quest Log Windowsusing the default, JRPG, Necromancer GUI, and Wheel2 styles. You can find themin the Prefabs/Unity Dialogue UIs folder.
How toConfigure a Quest Log Window
Whenopen, the window displays active and completed quests. It gets the titles,descriptions, and states of the quests from thePixelCrushers.DialogueSystem.QuestLog class, which in turn gets the data fromthe Item[] table.
To setup a quest log window, add a prefab from the Prefabs folder or create your ownGUI layout and add the Unity Quest Log Window component. The Prefabs foldercontains prefabs with different appearances.
Ifyou're creating your own layout, you'll need to create and assign the followingcontrols:
对话系统的一些统一的任务日志窗口使用默认,JRPG,死灵法师GUI提供了预建的问题,和wheel2风格。你可以找到他们在预设/团结对话UI文件夹。
如何配置任务日志窗口
当打开的窗口,显示活动完成的任务。它的标题,描述,并从pixelcrushers.dialoguesystem.questlog类任务状态,从而获取数据从项目[]表。
建立一个任务日志窗口,添加从prefabs文件夹预制或创建自己的GUI布局和添加统一的任务日志窗口组件。预制件文件夹包含具有不同形貌的问题。
如果你创建自己的布局,您需要创建和分配下列控件:
•Gui Root: The GUIRoot object.
•Scroll View: A GUIScrollView control that willcontain the list of active or completed quests.
•Active Button: When clicked, the scroll viewis populated with the list of active quests. This button should send theOnShowActiveQuests message.
•Completed Button: When clicked, the scrollview is populated with the list of completed quests. This button should sendthe OnShowCompletedQuests message.
•Quest Heading Source: Specifies whether to usethe item name or its Description field when displaying the quest heading. Ifyou've localized to different languages, set this to Description.
You donot need to assign the Close button. Instead, your close button (if you haveone) should send an OnClose message to the Unity Quest Log Window when clicked.
If youexamine any of the provided quest log prefabs, you'll see that you can addadditional controls, too, such as a containing window or other ornaments.
You canalso optionally set the GUI styles used by quest heading, body, and entry text.Different GUI styles are available for entries in the active, success, andfailure states – for example to use a GUI style with a green checkmark next tosuccessful entries and a different GUI style with a red X for failed entries.
You canalso customize the messages shown when there are no active or completed quests.You can create different copies of the layout with different text to localizethe quest log.
?根:GUI的guiroot对象。
?滚动视图:一个guiscrollview控制将包含活性或完成的任务列表。
?积极按钮:单击时,滚动视图是人口与主动任务列表。此按钮将onshowactivequests消息。
?完成按钮:单击时,滚动视图是人口稠密的已完成任务的清单。此按钮将onshowcompletedquests消息。
?任务标题来源:指定是否使用项目的名称或描述字段时,显示任务标题。如果你定位到不同的语言,这个设置的描述。
你不需要指定关闭按钮。相反,你的关闭按钮(如果有)应发送一个消息到统一OnClose任务日志窗口时,点击。
如果你查看任何所提供的任务日志的问题,你会发现你可以添加额外的控制,太,如含窗口或其他装饰品。
你也可以任意设置的任务标题,体用GUI风格,和输入文本。不同的GUI风格的活动,成功是可用的条目,和故障状态–例如使用一个GUI风格下成功的条目绿色复选标记和一个红色的X不同GUI风格的失败作品。
您还可以自定义显示在没有活动或完成任务的消息。您可以创建不同的副本不同文本的布局定位任务日志。
QuestTracker HUD
You canadd a basic quest tracker HUD to the Dialogue Manager object using the menuitem Window > Dialogue System > Component > Supplemental > QuestTracker. This HUD uses Unity GUI, and updates itself at the end ofconversations and when the player toggles tracking in the quest log window. Itdisplays quest titles as well as any entries if the quest has entries. You canuse it as-is or as a base for your own quest tracking HUD.
任务追踪平视显示器
您可以添加一个基本任务追踪HUD使用菜单项对话窗口>系统>组件>附加>任务追踪的对话管理器对象。这个HUD使用统一的图形用户界面,并更新自己在谈话结束,当玩家在任务日志切换窗口跟踪。它显示任务标题以及任何条目,如果任务条目。你可以作为或作为你自己的任务跟踪HUD基地使用它。
Questsand the Game World
TheDialogue System's Quest Log System provides the means to manage questdescriptions, quest states, and quest-related variables in the Lua environment.It doesn't, however, provide functionality to make changes in the game world,such as spawning monsters for a "kill" quest, because every game hasdifferent needs. In Blizzard's World of Warcraft, for example, the gameconstantly spawns mobs regardless of whether you have a quest or not. Inadventure games, on the other hand, you might not spawn generic mobs butinstead activate very specific, handmade boss characters. How quests take formin the game world is up to you.
TheDialogue System does provide some help, however. When you accept a quest in aDialogue System conversation, you can set the dialogue entry's Sequence field.There are many sequencer commands that you can use such as SetActive() toenable a deactivated boss character, or SendMessage() to send a message to aspawner to tell it to spawn a certain number of prefab monsters.
任务和游戏世界
对话系统的任务日志系统提供的手段来管理任务的描述,任务状态,与任务相关的变量在Lua环境。这不,但是,在游戏世界中做出改变,提供的功能,如产卵的怪物“杀”的任务,因为每一场比赛都有不同的需求。在暴雪的魔兽世界,例如,游戏不断滋生的暴徒不管你是否有一个任务或不。在冒险游戏,另一方面,你可能不会产生一般的怪物而激活非常具体的,手工制作的BOSS。多任务的形式在游戏中的世界是你的。
对话系统提供一些帮助,但是。当你在对话系统的对话接受任务,您可以设置对话输入序列的领域。有许多音序器的命令,可以使用诸如setactive()启用停用老板的性格,或sendmessage()将消息发送到一个产卵告诉它产生一定数量的预制的怪物。
UsingCore GameKit with Quests
If youuse Dark Tonic's Core GameKit, the Dialogue System provides custom sequencercommands to control Core GameKit's spawners. You can See the GameplayIntegration with Core GameKit section for more information.
使用核心GameKit的任务
如果你使用深色补品的核心GameKit,对话系统提供了自定义排序命令控制核心的GameKit的产卵。你可以看到游戏整合到核心的GameKit部分对于更多信息。
Usingthe Increment On Destroy Component
For"kill" quests and "gather" quests, you can use the DialogueSystem's Increment On Destroy component to update a Lua variable whenever thetarget object (e.g., a monster or a resource to gather) is destroyed.
Forexample, for a "kill 5 rats" quest you can add Increment On Destroyto the rats and set Variable property to the name of a variable in the dialoguedatabase such as "NumRatsKilled". When you kill a rat and its objectis destroyed, it will increment NumRatsKilled. (To decrement, simply set theIncrement property to a negative value.) In your conversation, you can checkthe value of Variable["NumRatsKilled"].
使用增量销毁组件
“杀”的任务和“聚集”的任务,你可以使用对话系统的增量破坏组件更新Lua变量每当目标对象(例如,一个怪物或资源收集)被破坏。
例如,一个“杀死5只老鼠”任务可以添加增量破坏对大鼠和变量设置属性的名称的变量,在对话中的数据库如“numratskilled”。当你杀死老鼠和它的对象被破坏,这将增加numratskilled。(递减,只需设置增量属性设置为一个负值。)你们的谈话,您可以检查变量的值[“numratskilled”]。
Save/Load System
Overview
Theprimary purpose of the Save/Load System, from the Dialogue System'sperspective, is to save and load the Lua environment, which containsinformation about which dialogue entries have already been visited, statusesand relationships, quest information, and more.
TheSave/Load System also allows you to save and load other game data. Using thePersistentDataManager class, you can save or load a game with a single line ofcode. Using the GameSaver component, you don't need to write any code at all.The LevelManager component adds functionality to save and load the player'scurrent level in multi-level games.
概述
保存/加载系统的主要目的,从对话系统的角度来看,是保存和加载lua环境,其中包含的信息有关的对话记录已访问,身份和关系,寻求信息,和更多。
保存/加载系统还允许你保存和加载游戏其他数据。使用persistentdatamanager类,您可以保存和加载游戏与一个单一的代码行。使用gamesaver组件,您不需要编写任何代码。该levelmanager组件添加功能来保存和多层次的游戏玩家的当前水平荷载。
SavedGame Data
A savedgame contains the current state of the dialogue database (e.g., quest states,which dialogue entries have been visited, etc.) as well as any data thatGameObjects have recorded into the Lua environment.
Savingconsists of two operations:
1.Recordingthe current state of GameObjects into the Lua environment, and
2.Retrievingthe Lua environment as a savegame string, which can be saved in PlayerPrefs orhandled however you want, such as writing to a file on disk, or saving to adatabase.
Loadingconsists of two similar operations:
1.Retrievinga savegame string (e.g., from PlayerPrefs, file, or database) and applying itto the Lua environment, and
2.Applyingthe Lua environment to the GameObjects.
保存游戏数据
保存的游戏中的对话数据库的当前状态(例如,任务状态的对话,作品已被访问,等等)以及任何数据对象已经记录到Lua环境。
节能包括两个操作:
1。记录对象的当前状态到Lua环境,和
2。检索Lua环境作为一个存档的字符串,可以保存在PlayerPrefs或无论你要处理,如写入磁盘上的文件,或保存到数据库。
负载由两个类似的操作:
1。检索存档的字符串(例如,从PlayerPrefs,文件,或数据库)并将其应用到Lua环境,和
2。应用Lua环境的对象。
WhatData Gets Saved
To keepthe saved game data size small, only the following information is recorded fromthe Lua environment:
•Actor[] table: all data
•Item[] table: only State,Entry_[1,2,3...]_State, and Track (for quest log system), ujnlessPersistentDataManager.includeAllItemData has been set to true.
•Location[] table: nothing
•Variable[] table: current value of eachvariable
•Conversation[] table: the SimStatus (whethereach dialogue entry has been offered or displayed), unlessPersistentDataManager.includeSimStatus has been set to false.
•Relationship and status information (see thestatus and relationship Chat Mapper Functions)
If youwant to capture specific data in your saved game, make sure it's recorded inone of the fields listed above. For example, the UFPS and Realistic FPSintegration scripts use the Variable[] and Actor[] tables, which are alwaysincluded in the saved game.
数据被保存
要保存的游戏数据量小,只有下面的信息是从Lua环境记录:
?演员表:[ ]的所有数据
?项目[ ]表:唯一的国家,entry_ [ 3 ] _state……,跟踪(任务日志系统),ujnlesspersistentdatamanager.includeallitemdata已设置为true。
?位置[ ]表:无
?变量[ ]表:每个变量的当前值
?[ ]表:谈话的simstatus(是否每个对话进入已提供或显示),除非persistentdatamanager.includesimstatus已设置为false。
?关系和状态的信息(见和关系聊天制图功能的状态)
如果你想捕捉你保存的游戏的具体数据,确保它的记录在上面列出的域。例如,超微粒子的和现实的FPS集成脚本使用变量[ ]和[ ]演员表,它总是包含在保存的游戏。
How ToSave Additional Data
To saveadditional data, write a delegate method and assign it toPersistentDataManager.GetCustomSaveData. The method should return a stringcontaining Lua code to run when reloading the game. See the Saving Custom Data(Inventory Table) recipe for a detailed example with code.
如何节省额外的数据
为了节省额外的数据,写一个委托方法和分配给persistentdatamanager.getcustomsavedata。该方法将返回一个字符串,Lua代码运行时重新加载游戏。看到保存自定义数据(量表)和代码的一个详细的例子的食谱。
PreparingGame Objects for Saving
Toprepare a game object for saving and loading, add one or more PersistentData*components. These components respond to messages to record the GameObjects'data to the Lua environment when saving, and to retrieve the GameObjects' datafrom the Lua environment when loading.
Whensaving a game, the persistent data manager sends an OnRecordPersistentData()message to all GameObjects to give them an opportunity to record their state inthe Lua environment. You can use the components described below or write yourown scripts that respond to OnRecordPersistentData.
Likewise,when loading a game, the persistent data manager sends anOnApplyPersistentData() message to all GameObjects to let them retrieve theirstate from the Lua environment and apply it.
NOTE:Call PersistentDataManager.LevelWillBeUnloaded() before loading a new level!Some persistent data components, such as Persistent Destructible, record datain the Lua environment when a game object is destroyed during play. Gameobjects are also be destroyed when you load a new level. In this case, youdon't want to record it in the Lua environment. The LevelWillBeUnloaded()method tells these components to ignore the OnDestroy() message.
ThesePersistentData components are currently available:
LevelManager Component
If yourplayer can move between levels, add the Level Manager component to yourDialogue Manager object.
制备用于保存游戏对象
准备一个游戏对象用于保存和加载,添加一个或多个persistentdata *成分。这些组件响应消息的记录对象的数据,lua环境当储蓄,并从Lua环境时加载的检索对象的数据。
保存游戏时,数据持久化管理器发送onrecordpersistentdata()消息给所有游戏对象给他们一个机会在Lua环境记录他们的状态。你可以使用下面描述的组件或自己写脚本,应对onrecordpersistentdata。
同样地,当加载游戏时,数据持久化管理器发送onapplypersistentdata()消息给所有物体能让他们从Lua环境找回他们的状态和应用。
注意:电话persistentdatamanager之前加载一个新的水平levelwillbeunloaded()!一些持久性数据的组件,如持续性破坏,记录数据在Lua环境时,一个游戏对象被破坏活动。游戏对象也被破坏,当你加载一个新的水平。在这种情况下,你不想它记录在Lua环境。该levelwillbeunloaded()方法告诉这些组件的忽视ondestroy()消息。
这些persistentdata组件是目前可用的:
级管理组件
如果你的球员可以移动之间的水平,增加管理层组件到您的对话管理器对象。
Whilethe name doesn't start with PersistentData, this component acts like apersistent data component. It records the player's current level inVariable["SavedLevelName"] so it can reload the player's currentlevel when reloading a game using the Game Saver component or theLevelManager.LoadGame() method. Add it to the Dialogue Manager so it's notdestroyed between level loads.
IfincludeAllItemData is ticked, saved-game data will include all fields in theItem[] table. Generally to keep saved-game data small you can keep thisunticked to only record Item[].State and Item[].Track.
IfincludeSimStatus is ticked, saved-game data will include conversations'SimStatus values. Otherwise these values will not be included, producingsmaller saved-game data. (For more info, see includeSimStatus property)
LevelManagercalls PersistentDataManager.LevelWillBeUnloaded() for you.
Thescene in the Examples/Save Load Example folder demonstrates the use ofLevelManager.
PersistentPosition Data Component
虽然名字不开始persistentdata,此组件的行为像一个持久数据组件。它记录玩家当前的水平变量[“savedlevelname”]可以重载的球员目前的水平时重新载入游戏用游戏程序组件或levelmanager loadgame()方法。将它添加到对话经理不破坏之间的水平荷载。
如果includeallitemdata打勾,保存游戏数据将包括在项目[]表的所有领域。通常要保存游戏数据小你可以保留这unticked只记录项目[ ] [ ]项。状态和跟踪。
如果includesimstatus打勾,保存游戏数据将包括谈话的simstatus值。否则,这些值将不会被包括,产生更小的保存游戏数据。(更多信息,见includesimstatus财产)
levelmanager电话persistentdatamanagerlevelwillbeunloaded()你。
在实例/现场保存负荷实例论证levelmanager使用文件夹。
持续的位置数据组件
Thiscomponent saves the game object's position and rotation.
In theexample above, Private Hart will save his position data into the Luaenvironment. When the player loads a saved game, Private Hart will be moved tothe correct position instead of the start position.
If theRecord Current Level checkbox is ticked, the object also records its currentlevel. If ticked, then when asked to apply this saved-game data later, theobject will only apply the data if the level matches.
PersistentActive Data Component
此组件保存游戏物体的位置和旋转。
在上面的例子中,私人哈特将拯救他的位置数据到Lua环境。当玩家加载保存的游戏,私人哈特将被移动到正确的位置,而不是开始的位置。
如果记录当前级别的复选框打勾,对象也记录其目前水平。如果勾选,当问到将保存的游戏对象数据后,将只有电平匹配应用数据。
持续活跃的数据组件
Thiscomponent sets a game object active or inactive based on a Lua condition.
In theexample above, the Force Field Controller object will activate or deactivatethe Force Field object based on a quest condition. It will activate the Force Fieldobject when the player loads a saved game in which the quest "Raise ForceField" has been completed successfully.
该组件设置一个游戏对象的活动或基于Lua状态无效。
在上面的例子中,力场控制器对象,将启用或禁用的力场基于任务状态的物体。这将激活的力场对象当玩家加载保存的游戏中,探索“提高力场”已成功完成。
PersistentDestructible Component
Thiscomponent records when a game object has been destroyed. When the saved gamedata is applied, if the game object has been previously destroyed, it will bedestroyed again. You can add this to destructible crates and barrels, enemies,and gathered crafting resources.
Itworks by recording true in a unique Lua variable. You don't have to define thisvariable ahead of time in your dialogue database, but you should assign avariable name to the component. If you don't assign a variable name, it willuse the name of the game object as the variable name.
持续性破坏的成分
这部分记录时,一个游戏对象被破坏了。当保存游戏数据的应用,如游戏对象被销毁,它会被摧毁了。你可以添加到破坏的板条箱和桶,敌人,和制造资源聚集。
它是通过一个独特的Lua变量的真实记录。你不必定义这个变量在您的对话数据库的时间,但是你应该到组件指定一个变量名。如果你不指定一个变量名,它将使用的游戏对象的名称作为变量名。
How toSave Multiple Destructibles
To savethe state of multiple destructible objects, you can:
•Use Persistent Destructible components,
•Use Persistent Active Data components, or
•Write your own script based onScripts/Templates/PersistentDataTemplate.cs.
如何保存多个destructibles
为了保存多个破坏对象的状态,你可以:
?使用持续破坏的成分,
?使用持久有效数据的组件,或
?基于脚本的编写/模板/ persistentdatatemplate.cs你自己的脚本。
UsingPersistent Destructible to Save Multiple Destructibles
To usePersistent Destructible, simply assign a unique variable name to each one.Optionally, you can leave the variable name blank and assign unique game objectnames.
使用持久性破坏保存多destructibles
使用持续性破坏,简单地分配一个唯一的变量名称的每一个。或者,你可以把变量名的空白和分配唯一的游戏对象的名称。
Theexample above shows an enemy with three components:
•Die On Take Damage: Destroys the game object whenit receives a TakeDamage message.
•Increment On Destroy: Increments a killcounter for a quest.
•Persistent Destructible: Records when"Enemy001" has been destroyed. The next time the level is loaded,this component will automatically destroy the game object.
上面的例子显示三部分组成一个敌人:
?死在采取破坏:破坏了游戏对象时,它接收到一个takedamage消息。
?增量:增量破坏杀死一个追求计数器。
?持续性破坏:记录时,“enemy001”已经被摧毁。下一次的水平加载,该组件将自动销毁游戏对象。
UsingPersistent Active Data to Save Multiple Destructibles
To usePersistent Active Data components:
1.Giveeach object a unique variable (for example, "Crate001","Crate002", etc.). You don't have to define the variable in thedialogue database. The Increment On Destroy script (next step) will create thevariable if it doesn't already exist.
2.Addan Increment On Destroy component to each destructible object. Assign thevariable name. When the object is destroyed, it will increment the value ofthis variable from 0 to 1.
3.Add aPersistent Active Data component to each destructible object.
◦Setthe target to the object.
◦Add aLua condition that compares the value of the variable to 0. When the saved datais applied, if the value is 0 the object will be active. If the value is 1 theobject will be inactive.
使用持久性活跃的数据保存多destructibles
使用持续活跃的数据组件:
1。给每个对象的唯一的变量(例如,“crate001”,“crate002”,等)。你不需要在数据库中定义的变量的对话。增量破坏脚本(下一步)将如果它不存在,创建变量。
2。添加一个增量破坏构件各破坏的对象。指定变量名称。当对象被销毁了,它会增加这个变量的值从0到1。
3。添加一个持续活跃的数据组件的每个可破坏的对象。
?设定目标对象。
?添加一个Lua状态相比,该变量的值为0。当保存数据时,如果该值为0的对象将被激活。如果该值为1的对象将是无效的。
WritingYour Own Persistent Data Components
Anycomponent that implements OnRecordPersistentData() and OnApplyPersistentData()can save and load persistent data. As a convenience, a template script isavailable in Scripts/Templates/PersistentDataTemplate.cs. Just make a copy ofthis script and customize it according to the instructions in the script'scomments.
编写自己的数据持久性组件
任何组件,实现了onrecordpersistentdata()和onapplypersistentdata()可以保存和加载数据持久性。为方便起见,一个模板脚本在脚本/模板/ persistentdatatemplate.cs是可用的。只是复制此脚本和定制,根据脚本的注释说明。
TheGameSaver component allows you to save and load games to PlayerPrefs withoutwriting any scripts. To use this component:
1.Addthe component to a GameObject.
2.Setthe Player Prefs Key (i.e., saved game slot) where the game will be saved andloaded. To make multiple slots, you can add more GamerSaver components tochange the Player Prefs Key field in each.
3.Tosave a game, send the message "SaveGame" to this component. You canuse a GUIButton or Send Message On Dialogue Event trigger to send the message,or call SaveGame() from a script.
◦ForGUIButtons, see GUI Controls
◦To adda trigger, use menu item Window > Dialogue System > Component >Triggers > Send Message On Dialogue Event
◦Scriptreference: PixelCrushers.DialogueSystem.GameSaver
4.Toload a game, send the message "LoadGame" to this component (or callit from a script).
5.Torestart the game, send the message "RestartGame" to this component(or call it from a script).
6.Torecord the state of the game without saving, for example when changing levels,send the "Record" message.
7.Toapply the saved state of the game, for example when returning to a level, sendthe "Apply" message.
8.Youcan also configure this component to save or load when the player"uses" the GameObject – that is, when the GameObject receives an"OnUse" message. To do this:
◦SetFunction On Use to Save or Load. This tells the component whether to save orload when it receives an OnUse message.
◦Sendthe message "OnUse" to this component or game object. For example,the sample Selector component sends OnUse when the player hits spacebar overthe object.
9.Ifyou tick Apply Game State When Loading Levels, then this component willautomatically apply the recorded game state as soon as the level is loaded.You're responsible for issuing the "Record" message before loadingthe level, in order to record the state of the level being exited.
If theGameSaver and LevelManager component are both on the Dialogue Manager object,then the GameSaver will use the LevelManager.LoadGame() method, which alsoloads the player's current level.
GameSavercalls PersistentDataManager.LevelWillBeUnloaded() for you.
该gamesaver组件允许你保存和加载游戏PlayerPrefs不用写剧本。使用这个组件:
1将该组件添加到一个游戏对象。
2。设置玩家设置的键(即,保存游戏槽),游戏将被保存和加载。使多个插槽,你可以在每个玩家设置的关键字段添加更多的gamersaver成分变化。
3。保存游戏,发送消息“存档”这个组件。你可以使用一个guibutton或发送消息的对话事件触发发送消息,或者叫savegame()从脚本。
?为guibuttons,看到GUI控件
?添加一个触发器,使用菜单项对话窗口>系统>组件> >发送消息的对话事件触发
?脚本参考:pixelcrushers.dialoguesystem.gamesaver
4。加载游戏,发送消息”loadgame”这一部分(或者说是从一个脚本)。
5。重新开始游戏,发送消息”restartgame”这一部分(或者说是从一个脚本)。
6。记录游戏的状态而不保存,例如改变水平时,把“记录”的信息。
7。将保存的游戏,例如当返回到一个水平,把“应用”的消息。
8。你也可以配置该组件保存或加载时,玩家使用的游戏对象–是,当对象接收到一个“onuse”的消息。这样做的:
?集函数使用保存或加载。这告诉组件是否保存或加载时,它接收到一个onuse消息。
?发送消息”onuse”这一组件或游戏对象。例如,样本选择组件发送onuse当玩家点击空格键的对象。
9。如果你在申请博弈状态加载水平时,则该组件将自动记录游戏状态尽快水平加载。你负责发放“记录”的消息在装货前的水平,以创纪录的水平退出状态。
如果gamesaver和levelmanager组件都在对话管理器对象,然后gamesaver将使用levelmanager。loadgame()方法,并加载的球员目前的水平。
gamesaver电话persistentdatamanagerlevelwillbeunloaded()你。
PersistentDataManagerClass
ThePersistentDataManager class provides static methods to:
•Record and apply persistent data to the Luaenvironment
•Get and apply savegame data
See thePixelCrushers.DialogueSystem.PersistentDataManager reference page for detailsabout the methods.
Briefly,to save game data call PersistentDataManager.GetSaveData(). The example belowsaves the game to a PlayerPrefs entry under the key "MySavedGame".
persistentdatamanager类
该persistentdatamanager类提供静态方法:
?记录并将数据持久性的Lua环境
?存档数据获取和应用
看到有关方法的细节pixelcrushers.dialoguesystem.persistentdatamanager参考页。
简要,保存游戏数据呼叫persistentdatamanager getsavedata()。下面的例子将游戏以一个关键的“mysavedgamePlayerPrefs条目下。
- using UnityEngine;
-
- namespace PixelCrushers.DialogueSystem {
-
- /// <summary>
- /// Allows you to save and load games to PlayerPrefs without writing
- /// any scripts. To use this component:
- ///
- /// -# Add this component to a game object.
- /// -# Set the playerPrefs key (i.e., saved game slot) where the game will be saved and loaded.
- /// To make multiple slots, you can add more GamerSaver components to change the playerPrefsKey
- /// field.
- /// -# To save a game, send the message "SaveGame" to this component (or call it from a script).
- /// For example, you can use the SendMessageOnConversation component to send the message.
- /// -# To load a game, send the message "LoadGame" to this component (or call it from a script).
- /// -# To restart the game, send the message "RestartGame" (or call it from a script).
- /// -# To record the state of the game without saving, for example when changing levels, send
- /// the "Record" message.
- /// -# To apply the saved state of the game, for example when returning to a level, send the
- /// "Apply" message.
- /// -# You can also configure this component to save or load when the player "uses" the game
- /// object. To do this:
- /// - Set Function On Use to Save or Load. This tells the component whether to save or load
- /// when it receives an OnUse message.
- /// - Send the message "OnUse" to this component or game object. For example, the sample
- /// Selector component sends OnUse when the player hits spacebar over the object.
- /// -# If you tick Apply Game State When Loading Levels, then this component will automatically
- /// apply the recorded game state as soon as the level is loaded. You're responsible for
- /// issuing the "Record" message before loading the level. You can use PersistentDataManager to
- /// do this.
- /// -# If the GameObject or a child contains a LevelManager, it will load using the LevelManager
- /// instead of just applying the saved-game data.
- /// </summary>
- public class GameSaver : MonoBehaviour {
-
- public enum FunctionOnUse { None, Save, Load, Restart };
-
- /// <summary>
- /// The root of the PlayerPrefs key where the game will be saved and loaded.
- /// </summary>
- public string playerPrefsKey = "savedgame";
-
- /// <summary>
- /// The default slot. This number is appended to playerPrefsKey to make the complete
- /// PlayerPrefs key.
- /// </summary>
- public int slot = 0;
-
- /// <summary>
- /// The function (save or load) to perform when receiving the "OnUse" message.
- /// </summary>
- public FunctionOnUse functionOnUse = FunctionOnUse.None;
-
- /// <summary>
- /// If <c>true</c>, applies the recorded game state
- /// </summary>
- public bool applyGameStateWhenLoadingLevels = false;
-
- /// <summary>
- /// If <c>true</c>, saved-game data will include all item fields. If <c>false</c>,
- /// it will only include quests' State and Track fields.
- /// </summary>
- public bool includeAllItemData = false;
-
- /// <summary>
- /// If <c>true</c>, saved-game data will include the offered/spoken status of
- /// all dialogue entries.
- /// </summary>
- public bool includeSimStatus = false;
-
- /// <summary>
- /// The starting level to use when restarting the game.
- /// </summary>
- public string startingLevel = string.Empty;
-
- /// <summary>
- /// If <c>true</c>, this game object isn't destroyed when you load a new level.
- /// </summary>
- public bool dontDestroyOnLoad = false;
-
- public void Awake() {
- if (dontDestroyOnLoad || applyGameStateWhenLoadingLevels) {
- DontDestroyOnLoad(this.gameObject);
- }
- PersistentDataManager.includeAllItemData = includeAllItemData;
- PersistentDataManager.includeSimStatus = includeSimStatus;
- }
-
- /// <summary>
- /// Upon receiving an "OnUse" message, this method saves, loads, or does nothing, based on
- /// the value of functionOnUse.
- /// </summary>
- public void OnUse() {
- switch (functionOnUse) {
- case FunctionOnUse.Save:
- SaveGame(); break;
- case FunctionOnUse.Load:
- LoadGame(); break;
- default:
- break;
- }
- }
-
- /// <summary>
- /// Saves the game under the PlayerPrefs key, adding the slot number to support multiple
- /// save game slots.
- /// </summary>
- /// <param name='slot'>
- /// The slot to use.
- /// </param>
- public void SaveGame(int slot) {
- if (string.IsNullOrEmpty(playerPrefsKey)) {
- if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: PlayerPrefs Key isn't set. Not saving.", new System.Object[] { DialogueDebug.Prefix }));
- return;
- }
- if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Saving game in slot {1}.", new System.Object[] { DialogueDebug.Prefix, slot }));
- string key = playerPrefsKey + slot.ToString();
- PlayerPrefs.SetString(key, PersistentDataManager.GetSaveData());
- }
-
- /// <summary>
- /// Saves the game in default slot 0.
- /// </summary>
- public void SaveGame() {
- SaveGame(slot);
- }
-
- /// <summary>
- /// Loads the game from the data saved under the PlayerPrefs key.
- /// </summary>
- public void LoadGame(int slot) {
- if (string.IsNullOrEmpty(playerPrefsKey)) {
- if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: PlayerPrefs Key isn't set. Not loading.", new System.Object[] { DialogueDebug.Prefix }));
- return;
- }
- string key = playerPrefsKey + slot.ToString();
- if (!PlayerPrefs.HasKey(key)) {
- if (DialogueDebug.LogWarnings) Debug.LogWarning(string.Format("{0}: No saved game in PlayerPrefs key '{1}'. Not loading.", new System.Object[] { DialogueDebug.Prefix, key }));
- return;
- }
- if (DialogueDebug.LogInfo) Debug.Log(string.Format("{0}: Loading save data from slot {1} and applying it.", new System.Object[] { DialogueDebug.Prefix, slot }));
-
- // Load using the LevelManager if available; otherwise just apply saved-game data:
- string saveData = PlayerPrefs.GetString(key);
- LevelManager levelManager = GetComponentInChildren<LevelManager>();
- if (levelManager != null) {
- levelManager.LoadGame(saveData);
- } else {
- PersistentDataManager.ApplySaveData(saveData, DatabaseResetOptions.KeepAllLoaded);
- }
- }
-
- /// <summary>
- /// Loads the game from default slot 0.
- /// </summary>
- public void LoadGame() {
- LoadGame(slot);
- }
-
- /// <summary>
- /// Saves the game using a string parameter for the slot number.
- /// </summary>
- /// <param name='slotString'>
- /// Slot string to convert to an int.
- /// </param>
- public void SaveGame(string slotString) {
- SaveGame(StringToSlot(slotString));
- }
-
- /// <summary>
- /// Loads the game using a string parameter for the slot number.
- /// </summary>
- /// <param name='slotString'>
- /// Slot string to convert to an int.
- /// </param>
- public void LoadGame(string slotString) {
- LoadGame(StringToSlot(slotString));
- }
-
- /// <summary>
- /// Restarts the game.
- /// </summary>
- public void RestartGame() {
- LevelManager levelManager = GetComponentInChildren<LevelManager>();
- if (levelManager != null) {
- levelManager.RestartGame();
- } else {
- DialogueManager.ResetDatabase(DatabaseResetOptions.RevertToDefault);
- if (string.IsNullOrEmpty(startingLevel)) {
- Application.LoadLevel(0);
- } else {
- Application.LoadLevel(startingLevel);
- }
- }
- }
-
- private int StringToSlot(string slotString) {
- int slot = 0;
- int.TryParse(slotString, out slot);
- return slot;
- }
-
- /// <summary>
- /// Records the state of the game.
- /// </summary>
- public void Record() {
- PersistentDataManager.Record();
- }
-
- /// <summary>
- /// Applies the recorded state of the game to the current scene.
- /// </summary>
- public void Apply() {
- PersistentDataManager.Apply();
- }
-
- /// <summary>
- /// If applyGameStateWhenLoadingLevels is <c>true</c>, applies the recorded state of the
- /// game to the newly-loaded level.
- /// </summary>
- /// <param name='level'>
- /// Level (not used).
- /// </param>
- void OnLevelWasLoaded(int level) {
- if (applyGameStateWhenLoadingLevels) Apply();
- }
-
- }
-
- }
上面这段源码其实我们后面可以用它来修改成我们需要的游戏存储界面,非常实用
To loadsaved game data, call PersistentDataManager.ApplySaveData(). The example belowloads a game from the same "MySavedGame" PlayerPrefs entry.
加载保存的游戏数据,persistentdatamanager applysavedata()呼叫。下面的例子将游戏从相同的“mysavedgamePlayerPrefs进入”。
You cancall Record() and Apply() manually during level changes. For example, you mightwant to keep track of an NPC's location between levels. Normally, when youreload a level, the NPC will be reset to its initial location in the scenefile. To track its location, add a PersistentPositionData component to the NPC.Before leaving the level, call PersistentDataManager.Record() to allow the NPCto record its position in the Lua environment. When returning to the level,call PersistentDataManager.Apply() to allow the NPC to retrieve its positionfrom the Lua environment.
你可以叫record()和apply()手动在水平的变化。例如,你可能想跟踪一个NPC的位置之间的水平。通常,当你加载一个水平,全国人民代表大会将被重置为其初始位置在场景文件。跟踪它的位置,添加一个persistentpositiondata组成全国人民代表大会。离开水平,呼叫前persistentdatamanager。record()允许NPC来记录在Lua环境位置。当回到水平,叫persistentdatamanager。apply()让人大为恢复其位置从lua环境。
includeAllItemDataproperty
Bydefault, the PersistentDataManager class records only the Item[].State andItem[].Track fields (used by quests) to keep the saved-game data size small. Ifyou have changed other fields at runtime and want to record their values, setincludeAllItemData to true.
includeallitemdata财产
默认情况下,只记录的persistentdatamanager类项目状态和项目[ ]。[ ]。跟踪领域(的任务)保持保存游戏数据大小小。如果你在运行时改变了其他领域,要记录他们的价值观,建立includeallitemdata真实。
includeSimStatusproperty
Bydefault, the PersistentDataManager class records the currently-loadedconversations' SimStatus values into the saved-game data. If you don't useSimStatus in your dialogue entry conditions, you may find it worthwhile to setthe includeSimStatus property to false. This will produce smaller saved-gamedata.
includesimstatus财产
默认情况下,该persistentdatamanager类记录当前加载的对话”simstatus值为保存游戏数据。如果你不使用你的对话simstatus准入条件,你会发现它值得设置includesimstatus属性设置为false。这将产生较小的保存游戏数据。
UseLevelWillBeUnloaded Before Loading Levels
CallPersistentDataManager.LevelWillBeUnloaded() before loading a new level.
Somepersistent data components, such as Persistent Destructible, record data in theLua environment when a game object is destroyed during play. Game objects arealso be destroyed when you load a new level. In this case, you don't want torecord it in the Lua environment. The LevelWillBeUnloaded() method tells thesecomponents to ignore the OnDestroy() message.
The LevelManagerand GameSaver components will automatically call LevelWillBeUnloaded() for you.
使用levelwillbeunloaded加载前的水平
呼叫persistentdatamanager之前加载一个新的水平levelwillbeunloaded()。
一些持久性数据的组件,如持续性破坏,记录数据在Lua环境时,一个游戏对象被破坏活动。游戏对象也被破坏,当你加载一个新的水平。在这种情况下,你不想它记录在Lua环境。该levelwillbeunloaded()方法告诉这些组件的忽视ondestroy()消息。
该levelmanager和gamesaver部件会自动调用levelwillbeunloaded()你。
Lua
TheDialogue System provides a complete Lua scripting environment.
对话系统提供了一个完整的Lua脚本环境。
AboutLua
Lua isa simple, general purpose scripting language. You don't have to use Lua whenwriting your conversations, but it does provide a very powerful method ofcontrolling the flow of conversations, checking and changing quest states, andmore.
Formore information on Lua itself, see www.lua.org.
You maywish to jump straight to the Common Lua Examples for the Dialogue Systemsection.
TheDialogue System utilizes Chat Mapper's data model. In Chat Mapper, you cancontrol conversations by writing conditions and running short scripts in Lua.Information about all actors, items, locations, variables, and conversations isstored in Lua tables. The Chat Mapper manual(http://www.chatmapper.com/documentation/) has more info about Lua andspecifically the tables that the Dialogue System uses, in the section titledScripting with Lua.
TheDialogue System implements all Chat Mapper Lua functionality and providesadditional features to work with Lua in Unity. An in-game Lua Console componentis also available.
Jumpto: Common Lua Examples for the Dialogue System.
关于Lua
Lua是一个简单的,通用的脚本语言。你不必使用Lua写你的对话的时候,但它提供了一个控制会话的流量非常强大的方法,检查和更换任务状态,和更多。
在Lua本身的更多信息,见www.lua.org。
你可以直接跳到的对话系统部分常见的Lua的例子。
对话系统利用聊天映射的数据模型。在聊天的映射,你可以通过写Lua脚本运行条件和控制短对话。所有的演员,项目,地点,变量的信息,和会话存储在Lua表。聊天制图手册(http://www.chatmapper.com/documentation/)有更多的信息关于Lua和专门的对话系统使用的表,在节题为脚本语言Lua。
对话系统实现了所有的聊天制图Lua功能并提供额外的功能,用Lua在统一中工作。游戏中的lua控制台组件也可。
跳转到:为对话系统常见的Lua的例子。
SpecialLua Variables & Functions
ChatMapper Variables
Thesedialogue system-specific variables are available to you in your Lua scripts.More details are available in Chat Mapper's online documentation.
•Actor table containing information about allactors
•Item table containing information about allitems (also aliased as Quest in the Dialogue System)
•Location table containing information aboutall locations
•Variable table containing information aboutall user-defined variables
•Conversation table containing informationabout all conversations
•Variable["Alert"]: Set this variableto make the Dialogue System display an alert. (see Alerts)
•Variable["Actor"]: The name of theactor in the current conversation (if any).
•Variable["Conversant"]: The name ofthe conversant in the current conversation (if any).
特殊的Lua变量和函数
聊天映射变量
这些对话系统特定的变量在您的lua脚本供你。更多的细节在聊天中映射的在线文档是可用的。
?演员表包含所有参与者的信息
?项目表包含所有的项目信息(也混杂在对话系统的任务)
?位置表包含所有位置的信息
?变量表包含所有用户定义的变量的信息
?会话表包含所有会话信息
?变量[“警报”]:设置这个变量使对话系统显示一个警告。(见通知)
?变量[“演员”]:在当前会话的演员的名字(如果有)。
?变量[“精通”]:在当前会话的熟悉的名称(如果有)。
ImportantNote About Table Indices
TheDialogue System follows a convention established by Chat Mapper: In Chat Mappertables, replace all space characters and hyphens with underscores in keys. Thisonly applies to table indices, which is the part inside the square brackets orafter the "." if you're referencing a field inside a table element.
Examples:If you have a variable named "Kissed the Frog", reference it in Luaas: Variable["Kissed_the_Frog"].
If youractor is named "Mister Big-Man", reference his table entry asActor["Mister_Big_Man"].
If theactor has a field named "Favorite Color", you can reference it asActor["Mister_Big_Man"].Favorite_Color.
表指标的重要注意事项
对话系统遵循公约建立了:在聊天聊天映射映射表,代替所有的空间特征和连字符和下划线在钥匙。这只适用于表的指数,这是一部分放在方括号内或之后”。“如果你引用的字段在表元。
例子:如果你有一个变量名为“吻了青蛙”,参考在lua:变量[“kissed_the_frog”]。
如果你的主角被命名为“先生的大男人”,参考他的表条目作为演员的“mister_big_man [”]。
如果演员有一个名为“最喜欢的颜色”的领域,你可以参考它作为演员[”] favorite_color mister_big_man”。
ChatMapper Functions
TheseChat Mapper functions are available in Lua to record statuses and relationshipvalues. The descriptions of these functions come from the Chat Mapperdocumentation:
MutualStatus
ChatMapper can track a status that is defined between any two assets, which isreferred to as a mutual status. To set or access a mutual status, use thefollowing two functions:
•SetStatus(Asset1, Asset2, "statusvalue")
•GetStatus(Asset1, Asset2)
聊天映射函数
这些聊天制图功能可在Lua记录状态和关系价值。这些功能的描述来自聊天映射文件:
相互的状态
聊天器可以跟踪状态,定义的任何两个之间的资产,这被称为一个共同的状态。设置或获取共同的状态,使用以下两个功能:
?SetStatus(asset1,asset2,“状态值”)
?getStatus(asset1,asset2)
Relationships
ChatMapper will also track numerical relationship values between any two actors.Relationships can be useful for controlling NPC responses based on arelationship value. The following four functions can be used to controlrelationship values:
•SetRelationship(Actor1, Actor2, "relationshiptype", value)
•GetRelationship(Actor1, Actor2,"relationship type")
•IncRelationship(Actor1, Actor2,"relationship type", incrementAmount)
•DecRelationship(Actor1, Actor2,"relationship type", decrementAmount)
Pleasenote that the Dialogue System does not implement the functions below, sincethey have no meaning outside Chat Mapper:
•TrackVariable(Table, "variablename")
•TrackStatus(Asset1, Asset2)
•TrackRelationship(Actor1, Actor2,"relationship type")
关系
聊天器也会跟踪任何两个演员之间的数值关系。关系可以控制NPC反应基于关系价值是有用的。以下四个函数可以用来控制关系的价值:
?setrelationship(actor1,ACTOR2,“关系型”,值)
?getrelationship(actor1,ACTOR2,“关系型”)
?increlationship(actor1,ACTOR2,“关系型”,incrementamount)
?decrelationship(actor1,ACTOR2,“关系型”,decrementamount)
请注意,对话系统没有实现以下功能,因为他们在无意义的聊天器:
?trackvariable(表,“变量名”)
?trackstatus(asset1,asset2)
?trackrelationship(actor1,ACTOR2,“关系型”)
OtherUseful Functions
RandomElement()Function
TheDialogue System provides a Lua function RandomElement(). You can use this incombination with the [lua()] tag to insert a random element from a list intoyour dialogue text.
Thesyntax of RandomElement is:
其他有用的功能
randomelement()功能
对话系统提供一个Lua函数randomelement()。你可以使用这个lua()]与[标签组合随机插入元素的列表到你的对话文本。
randomelement的语法是:
wherestring is a string of elements separated by the horizontal bar character ('|').
在串是一个字符串的字符分隔的元素(单杠的|’)。
RandomElement()Example
Say youhave an NPC that greets the character with a random honorific title. In yourdialogue database, click on the Variables tab and define a variable namedHonorifics that contains this list:
randomelement()例子
说你有个NPC迎接特征与一个随机的尊称。你在对话中的数据库,点击变量标签定义的变量命名敬语包含此列表:
Then,in the dialogue entry, set the text to:
•Dialogue Text: Greetings,[lua(RandomElement(Variable["Honorifics"]))] One!
Theresult is that the NPC will randomly use one of the element in the Honorificslist, such as "Greetings, Esteemed One!" or "Greetings, GreatOne!"
Thesource string doesn't have to be set at design time. You can generate itdynamically during gameplay. You can use RandomElement() for other purposes,too, such giving the player a random item upon completion of a quest, or evenchoosing a random quest out of a list.
然后,在对话输入,设置文本:
?对话的文字:问候,[ lua(randomelement(变量[“敬语”]))]一!
结果是,NPC会随机使用一个列表中的元素的敬语,如“问候,尊敬的人!”或“问候,伟大的人!”
源字符串不需要在设计时设置。您可以生成动态的游戏中。你可以使用randomelement()用于其他目的,太,这样给玩家在一个任务完成的随机项,或者选择一个随机的任务的列表。
Lua InScripts
TheDialogue System uses Liu Junfeng's Lua Interpreter(http://www.codeproject.com/Articles/228212/Lua-Interpreter), made availableunder MIT License. The included version of Lua Interpreter has been modified tobe compatible with Windows Store and Windows Phone projects.
HistoricalNote: Versions 1.0 - 1.2.4.2 used George Foot's KopiLuaInterface(https://github.com/gfoot/kopiluainterface), which is another excellent Luaimplementation. However, it heavily uses a programming technique calledreflection that is not fully supported in the restrictive Windows Store andWindows Phone environments. This prompted a switch to Lua Interpreter.
TheDialogue System provides a PixelCrushers.DialogueSystem.Lua static wrapperclass which isolates the actual Lua implementation from the rest of theDialogue System. If you want to use a different Lua implementation, you onlyneed to replace this class and update the DialogueLua class, which includessome optimizations that directly reference the Lua Interpreter class for speed.
The Luaclass is the easiest way to run Lua directly.
However,the easiest way to directly access the Dialogue System's Lua data is with themethods described below in the PixelCrushers.DialogueSystem.DialogueLua staticclass.
Lua脚本
对话系统采用刘俊峰的Lua解释器(HTTP:/ / www.codeproject。COM /物品/ 228212 /Lua解释器),提供在MIT许可证。包含的Lua解释器版本已改为Windows商店和Windows手机项目兼容。
历史注:版本1 - 1.2.4.2用脚的kopiluainterface乔治(HTTPS:/ / GitHub。COM / gfoot /kopiluainterface),这是一个极好的Lua实现。然而,它大量使用一种编程技术称为反射不在限制Windows商店和Windows手机环境完全支持。这促使一个开关的Lua解释器。
对话系统提供了一个pixelcrushers.dialoguesystem.lua静态包装类使实际Lua实现从系统的其余部分的对话。如果你想使用一个不同的Lua实现,你只需要替换这类和更新dialoguelua类,其中包括一些优化,直接参考lua解释器类速度。
lua阶级是直接运行Lua最简单的方法。
然而,直接访问对话系统的lua数据的最简单方法是使用下面描述的pixelcrushers.dialoguesystem.dialoguelua静态类的方法。
Easy-AccessDialogueLua Methods
To getand set data in the standard Dialogue System Lua tables – Actor[], Item[],Location[] and Variable[] – you can use these methods:
•DialogueLua.GetVariable(): Gets the value of avariable.
•DialogueLua.SetVariable(): Sets the value of avariable.
•DialogueLua.GetActorField(): Gets the value ofa field in an actor.
•DialogueLua.SetActorField(): Sets the value ofa field in an actor.
•DialogueLua.GetItemField(): Gets the value ofa field in an item.
•DialogueLua.SetItemField(): Sets the value ofa field in an item.
•DialogueLua.GetQuestField(): Gets the value ofa field in a quest. Equivalent to GetItemField, since quests use the Item[]table.
•DialogueLua.SetQuestField(): Sets the value ofa field in a quest. Equivalent to SetItemField, since quests use the Item[]table.
•DialogueLua.GetLocationField(): Gets the valueof a field in a location.
•DialogueLua.SetLocationField(): Sets the valueof a field in a location.
易于访问的dialoguelua方法
获取和对话系统标准Lua表–演员[ ]集数据,项目[ ],[ ]和[ ]位置变量–可以使用这些方法:
?dialoguelua。getvariable():得到一个变量的值。
?dialoguelua。setvariable():设置一个变量的值。
?dialoguelua。getactorfield():获取字段的值在一个演员。
?dialoguelua。setactorfield():套在演员字段的值。
?dialoguelua。getitemfield():获取字段的值在一个项目。
?dialoguelua。setitemfield():集中的一个字段的值。
?dialoguelua。getquestfield():获取字段的值在一个任务。相当于getitemfield,由于任务使用项目[ ]表。
?dialoguelua。setquestfield():设置任务字段的值。相当于setitemfield,由于任务使用项目[ ]表。
?dialoguelua。getlocationfield():获取字段的值在一个位置。
?dialoguelua。setlocationfield():套在位置字段的值。
TheDialogueLua class automatically convert table indices' spaces and hyphens tounderscores. When using the DialogueLua class, you can ignore the note inImportant Note About Table Indices. (However, when using the Lua class, youmust remember to convert spaces and hyphens to underscores.)
TheDialogueLua.GetXXX() methods return a Lua.Result value. To get a basic datatype, use properties such as AsString, AsInt, AsFloat, and AsBool.
Elementsin the Actor[], Item[], and Location[] tables are sub-tables, so you can usethe DialogueLua.GetXXXField() methods.
Elementsin the Lua Variable[] table are regular data types (Boolean, string, number,etc.), so you cannot use the DialogueLua.GetXXXField() methods. Instead, useDialogueLua.GetVariable(). Examples:
该dialoguelua类自动转换表指标的空间和连字符为下划线。使用dialoguelua类的时候,你可以忽略表指标重要事项说明。(然而,使用Lua类,当你必须记得把空间和连字符为下划线。)
该dialoguelua。getxxx()方法返回一个Lua值。结果。要获得一个基本的数据类型,使用性能如asstring,asint,asfloat,和asbool。
在演员[ ]元,项目[ ],[ ]表和子表的位置,所以你可以使用dialoguelua getxxxfield()方法。
在Lua变量[ ]表元素的数据类型(布尔,字符串规则,数,等),所以你不能使用dialoguelua getxxxfield()方法。相反,使用dialogueluagetvariable()。的例子:
Elementsin the Item[], Location[], and Actor[] tables are records. A record has sub-elementscalled fields. For example, an Actor record might have fields for Name, Age,IsPlayer, etc. To use the DialogueLua functions with them, you need to specifywhich field you want. For example:
在项目[ ] [ ]元,位置,和演员[ ]表记录。一个记录的子元素,称为域。例如,一个演员的记录可能域名字,年龄,isplayer,等。利用dialoguelua功能,您需要指定哪个领域你想要的。例如:
Rememberthat these methods are in DialogueLua, which provides methods for workingspecifically with Dialogue System data. The Lua class, described below,provides more general-purpose access to the Lua environment.
记住,这些方法在dialoguelua,为对话系统数据的具体工作提供方法。下面描述的lua阶级,,提供了更多的通用访问Lua环境。
LuaClass
ThePixelCrushers.DialogueSystem.Lua static class provides access to the Luaenvironment through these functions:
•Lua.Run(): Runs Lua code and returns aLua.Result structure with properties such as AsString, AsInt, AsBool, etc. UseLua.Run() to access Dialogue System variables from within your Unity code, asin these examples:
Lua类
该pixelcrushers.dialoguesystem.lua静态类,通过这些功能提供存取Lua环境:
?Lua。run():运行Lua代码并返回一个Lua。结果结构与性能如asstring,asint,asbool使用Lua,等。run()从Unity代码访问对话系统变量,如上述的例子:
•Lua.IsTrue(): Runs Lua code and returns trueif the Lua result is true, otherwise false. For example:
?Lua。istrue():运行Lua代码返回TRUE如果Lua的结果是真实的,否则为false。例如:
Rememberthat Lua.Run() returns a special type (called Lua.Result) that can be aboolean, string, or number. To get the boolean value, you need to add".AsBool", as in this example:
记住,Lua。run()返回一个特殊类型(称为lua。结果),可以是一个布尔,字符串,或数量。得到的布尔值,你需要添加”。asbool”,如:
Similarly,if your variable is a number, you can do this:
同样的,如果你的变量是一个数字,你可以这样做:
Noteabout Lua & Dialogue Database Loading
TheDialogue System delays loading of the master dialogue database until the datais needed. This avoids potentially long delays during Start() if you have avery large initial database. If you want to load the database manually (forexample to run Lua commands on its contents) before the database has been usedfor a conversation, bark, or sequence, callDialogueManager.PreloadMasterDatabase() first.
关于Lua与对话数据库加载
对话系统的延迟加载的大师对话数据库到数据是必要的。这避免了潜在的长时间的延迟在start()如果你有一个非常大的初始数据库。如果你想装载数据库手动(例如运行Lua命令对其内容)在数据库已被用于一个会话,树皮,或序列,称dialoguemanagerpreloadmasterdatabase()第一。
Noteabout Lua & Dialogue Database Loading
TheDialogue System delays loading of the master dialogue database until the datais needed. This avoids potentially long delays during Start() if you have avery large initial database. If you want to load the database manually (forexample to run Lua commands on its contents) before the database has been usedfor a conversation, bark, or sequence, call DialogueManager.PreloadMasterDatabase()first.
SettingLua Observers
You canset watches on Lua expressions using these methods:
DialogueManager.AddLuaObserver():Adds a watch on a Lua expression that will be checked on a specified frequency.The frequency can be EveryUpdate, EveryDialogueEntry, or EndOfConversation. Ifthe expression changes, the Dialogue System will invoke a delegate that takesthe form:
关于Lua与对话数据库加载
对话系统的延迟加载的大师对话数据库到数据是必要的。这避免了潜在的长时间的延迟在start()如果你有一个非常大的初始数据库。如果你想装载数据库手动(例如运行Lua命令对其内容)在数据库已被用于一个会话,树皮,或序列,称dialoguemanagerpreloadmasterdatabase()第一。
设置Lua观察员
你可以设置表在Lua表达式中使用这些方法:
dialoguemanager。addluaobserver():加上一个Lua表达,将在指定的频率检查表。频率可以everyupdate,everydialogueentry,或endofconversation。如果表达的变化,对话系统将调用的委托,采取的形式:
You canremove watches using DialogueManager.RemoveLuaObserver() orDialogueManager.RemoveAllLuaObservers().
Note:For best performance, limit the number of watches you set, especially when thefrequency is EveryUpdate. Each watch requires an extra Lua call to evaluate thecurrent state of the watch expression.
你可以使用dialoguemanager删除表。removeluaobserver()或dialoguemanagerremoveallluaobservers()。
注:为了获得最佳性能,极限的手表你设置的数量,特别是当频率everyupdate。每个手表需要一个额外的luacall评价表表达式的当前状态。
CommonLua Examples for the Dialogue System
Lua isa complete, full-featured language. It makes the Dialogue System extremelypowerful. Using Lua, you can add very sophisticated behavior to your games.
Buteven using only two operations – test for equality ("==") andassignment ("=") – you can still make very complex, interactivedialogue without having to do anything else in Lua.
TestingValues
Hereare some examples to make a dialogue entry conditional. The entry will only beconsidered if the condition is true. These Lua statements would go in theentry's Condition field.
在对话系统中常见的Lua的例子
Lua是一种完整的,功能齐全的语言。这使得对话系统非常强大。使用Lua,您可以添加到您的游戏非常复杂的行为。
但即使只使用两个操作平等–试验(“= =”)和分配(“=”)–仍然可以做很复杂的,交互式的对话而不必在Lua中做任何事情。
测试值
这里有一些例子来进行对话的入口条件。本条目只会如果条件为真的考虑。这些Lua语句会进入的条件字段。
•Check if a quest is in a specific state (notethe use of double equals "==" to test equality):
?检查如果一个任务是在一个特定的状态(注意使用双等于“= =”测试平等):
(Experiencedprogrammers: Note that in Lua the logical operators are ~=, and and or, not !=,&& and ||.)
Youcould also use conditions like the ones above in a trigger's Conditions. Notethat, in triggers, you can also add quest conditions, which are more convenientfor checking quest statuses than writing Lua conditions.
Notethat, in the Dialogue System Quest[] is an alias for Item[]. So your Lua codecan use this form instead:
(有经验的程序员:注意,Lua中的逻辑运算符~ =,和,或者,不!=,&&和| |。)
你也可以使用条件像上面的触发器中的条件。在触发器,注意,你也可以添加任务的条件,这是检查任务状态比写Lua条件更方便。
注意,在对话系统的任务是[ ] [ ]项目的别名。所以你可以用这个代替形式Lua代码:
Thisalias is also defined in the provided Chat Mapper template so you can use it inChat Mapper, too.
这个别名也被定义在提供的聊天制图模板,你可以用它聊天器,太。
AssigningValues
Hereare some examples to set values. You could use them in a dialogue entry'sScript field or in the Lua On Dialogue Event trigger component described inOther Triggers.
分配值
这里有一些例子来设定值。你可以使用他们在一个对话的脚本进入现场或在对话事件触发其他触发器组件描述Lua。
•Set a quest to a specific state (note the useof single equals for assignment):
?设定一个任务到一个特定的状态(注意分配单等于使用):
•Increment a variable's value:
?增加一个变量的值:
(Experiencedprogrammers: In Lua, the string concatenation operator is .., not +.)
(有经验的程序员:在Lua中,字符串串联运算符是..,不是+。)
LuaConsole
The LuaConsole component is available in the menu Window > Dialogue System >GameObject > Create (to create a new game object with a Lua Consolecomponent) or Window > Dialogue System > Component > Lua Console (toadd a Lua Console component to the currently-selected game object).
Duringgameplay, tilde plus the L key toggles the console, which allows you to enterLua commands and see their results. You can use the up and down arrow keys tomove through the history of your Lua commands.
The LuaConsole is useful for debugging Lua commands and to examine the internal stateof the Lua environment. For example, if you have a dialogue entry that'ssupposed to set a variable to a certain value, you can use the console to checkthat the variable is set. The console displays the return values of yourcommands. It doesn't display the output of print statements. To examine thevalue of a variable, use syntax such as:
Lua控制台
Lua控制台组件可在菜单“窗口>> >创建对话系统的游戏对象(创建一个Lua主机组成新的游戏物体)或窗口>对话系统>组件> Lua控制台(添加一个Lua控制台组成为当前选定的游戏对象)。
在游戏中,波浪线加L键切换控制台,它允许你进入Lua命令并查看结果。您可以使用上下箭头键移动通过你的Lua命令历史。
Lua Lua命令控制台是用于调试和检查的Lua内部环境状态。例如,如果你有一个对话的条目,应该设置一个变量为一定值,你可以使用控制台来检查该变量设置。控制台显示你命令的返回值。它不显示报表的打印输出。检查变量的值,使用的语法等:
You canalso use the console to manually set values if you want to test specific partsof your conversations.
你也可以使用控制台手动设置的值,如果你想测试您的会话的特定部分。
Related:
•Dialogue Creation (Lua conditions and userscripts)
•Triggers (Lua triggers)
•Alerts (Lua to display alerts)
•Quest Log System (Lua for checking andmodifying quest states)
相关的:
?创建对话(lua条件和用户脚本)
?触发器(lua触发器)
?警报(lua显示)
?任务日志系统(Lua检查和修改任务状态)
Script Overview
As a convenience, the Dialogue System comeswith precompiled DLLs that will significantly shorten your compile times.Complete source code is also provided in a Unity package. See Installation forinstructions on unpacking the source code.
为方便起见,对话系统自带的预编译的DLL,将大大缩短你的编译时间。完整的源代码也在一个统一的包提供。看到在解压源代码安装说明。
Namespaces
Allsource code is contained within the namespace hierarchyPixelCrushers.DialogueSystem.
Incode, you'll probably only ever need to reference the scripts inPixelCrushers.DialogueSystem, and possiblyPixelCrushers.DialogueSystem.UnityGUI. However, this is the complete namespacehierarchy:
命名空间
所有的源代码是包含在命名空间pixelcrushers.dialoguesystem。
在代码中,你可能只需要参考pixelcrushers.dialoguesystem脚本,并可能pixelcrushers.dialoguesystem.unitygui。然而,这是完整的命名空间层次结构:
•PixelCrushers.DialogueSystem: The mainDialogue System source code
◦UserInterfaces:
◦PixelCrushers.DialogueSystem.UnityGUI:UIs implemented using Unity GUI
◦PixelCrushers.DialogueSystem.DaikonForgeGUI:Daikon Forge GUI support
◦PixelCrushers.DialogueSystem.NGUI:NGUI support
◦PixelCrushers.DialogueSystem.TK2D:2D Toolkit UI support
◦Frameworks:
◦PixelCrushers.DialogueSystem.ActionRPG2D:2D Action RPG Starter Kit support
◦PixelCrushers.DialogueSystem.AdventureCreator:Adventure Creator support
◦PixelCrushers.DialogueSystem.BehaviorDesigner:Behavior Designer support
◦PixelCrushers.DialogueSystem.CoreGameKit:Core GameKit support
◦PixelCrushers.DialogueSystem.PlayMaker:PlayerMaker support
◦PixelCrushers.DialogueSystem.plyGame:plyGame support
◦PixelCrushers.DialogueSystem.RealisticFPSPrefab:Realistic FPS Prefab support
◦PixelCrushers.DialogueSystem.UFPS:Ultimate FPS support
◦Other:
◦PixelCrushers.DialogueSystem.FaceFX:FaceFX support
◦PixelCrushers.DialogueSystem.uSequencer:uSequencer support
Luafunctionality is provided through KopiLua and LuaInterface and are used underMIT License. KopiLua is maintained by Vinicius Jarina. KopiLuaInterface iswritten and maintained by George Foot. They are contained in the namespacesKopiLua and LuaInterface.
lua的功能是通过kopilua和LuaInterface提供在MIT许可使用。kopilua由jarina也保持。kopiluainterface是书面,由乔治脚保持。他们都包含在命名空间kopilua和LuaInterface。
Core
TheDialogue System uses a Model-View-Controller (MVC) architecture, where theModel is the state of the dialogue database and active conversation, View isthe dialogue UI, and the Controller is the module that mediates between themodel and the view.
TheCore folder contains the Model-View-Controller scripts as well as custom editorscripts, the DialogueSystemController component that provides a single controlinterface for the MVC, and the DialogueManager singleton class that wraps theDialogueSystemController for easy access.
核心
对话系统使用一个模型视图控制器(MVC)体系结构,在模型的数据库和主动对话会话的状态,看来是对话的界面,和控制器模块介导的模型和视图之间。
核心文件夹包含的模型-视图-控制器脚本以及自定义编辑器的脚本,该dialoguesystemcontroller组件,提供了一种MVC单一的控制界面,和dialoguemanager单例类包装dialoguesystemcontroller轻松访问。
Supplemental
TheSupplemental folder contains important Dialogue System modules that are builton top of the core modules. These include the Triggers, Save/Load System, QuestLog System, and Unity GUI implementations of IDialogueUI and IBarkUI.
补充
添加文件夹包含重要的对话系统是建立在顶部的核心模块。这些包括触发器,保存/加载系统,日志系统,统一的GUI实现idialogueui和ibarkui。
ThirdParty Support
TheThird Party Support folder contains Unity Packages of scripts to supportthird-party products such as NGUI, uSequencer, and PlayMaker.
第三方的支持
支持文件夹包含脚本包的统一支持第三方的产品如usequencer NGUI,第三方,和球员。
Templates
TheTemplates folder contains templates that you can copy to create your ownimplementations of dialogue UIs, bark UIs, sequencer commands, and persistentdata recorders
模板
模板文件夹包含的模板,您可以复制创建你自己的对话的用户界面,实现界面的树皮,音序器的命令,和持续的数据记录器
NotificationMessages
Conversation,Bark, and Sequence Messages
TheDialogue System sends these messages to the participants involved:
•OnConversationStart(Transform actor): Sent atthe start of a conversation. The actor is the other participant in theconversation. This message is also broadcast to the Dialogue Manager object andits children.
•OnConversationEnd(Transform actor): Sent atthe end of a conversation. The actor is the other participant in theconversation. This message is also broadcast to the Dialogue Manager object andits children after the dialogue UI has closed.
•OnConversationCancelled(Transform actor):Broadcast to the Dialogue Manager object (not the participants) if aconversation ended because the player presses the cancel key or button duringthe player response menu.
•OnConversationLine(Subtitle subtitle): Sentwhenever a line is spoken. See the PixelCrushers.DialogueSystem.Subtitlereference. This message is also broadcast to the Dialogue Manager object andits children.
•OnConversationLineCancelled(Subtitlesubtitle): Broadcast to the Dialogue Manager object (not the participants) ifthe player presses the cancel key or button while a line is being delivered.Cancelling causes the Dialogue System to jump to the end of the line andcontinue to the next line or response menu.
•OnConversationTimeout(): Sent to the DialogueManager object (not the participants) if the response menu times out. TheDialogueSystemController script handles timeouts according to its displaysettings. You can add your own scripts to the Dialogue Manager object that alsolistens for this message.
•OnBarkStart(Transform actor): Sent at thestart of a bark. The actor is the other participant.
•OnBarkEnd(Transform actor): Sent at the end ofa bark. The actor is the other participant.
•OnSequenceStart(Transform actor): Sent at thebeginning of a cutscene sequence. The actor is the other participant. (Sequencescan have an optional speaker and listener.)
•OnSequenceEnd(Transform actor): Sent at theend of a sequence. The actor is the other participant.
通知消息
谈话,树皮,和序列信息
对话系统发送这些信息所涉及的参与者:
?onconversationstart(变换演员):在开始一段对话派。演员是会话中的其他参与者。这个消息也被广播到对话管理器对象和它的孩子。
?onconversationend(变换演员):在谈话结束发送。演员是会话中的其他参与者。这个消息也被广播到对话管理器对象和它的孩子们在对话UI已关闭。
?onconversationcancelled(变换演员):广播的对话管理器对象(而不是参与者)如果一段谈话结束因为玩家按下取消键或按钮菜单中的球员的反应。
?onconversationline(字幕字幕):发送每当线是口语。看到pixelcrushers.dialoguesystem.subtitle参考。这个消息也被广播到对话管理器对象和它的孩子。
?onconversationlinecancelled(字幕字幕):广播的对话管理器对象(而不是参与者)如果玩家按下取消键或按钮而线被传递。取消导致对话系统跳到终点,并继续下一行或响应菜单。
?onconversationtimeout():发送到对话管理器对象(而不是参与者)如果响应菜单超时。该dialoguesystemcontroller脚本处理超时按其显示设置。您可以添加您自己的脚本的对话管理器对象,也听了这个消息。
?onbarkstart(变换演员):在一个皮开始发送。演员的其他参与者。
?onbarkend(变换演员):在一个皮端发送。演员的其他参与者。
?onsequencestart(变换演员):在一个动画序列开始发送。演员的其他参与者。(序列可以有一个可选的演讲者和听众。)
?onsequenceend(变换演员):在一个序列的端发送。演员的其他参与者。
Thissample script logs conversation activity:
An extended version of thisscript is located in Examples/Scripts.
Thestring DialogueManager.LastConversationStarted records the last conversationthat was started, or the current conversation if a conversation is active.
一个扩展版本的脚本位于实例/脚本。
字符串dialoguemanager.lastconversationstarted记录的最后启动的会话,或者当前会话如果谈话是活动的。
SubtitleContinue Button
Bydefault, the Dialogue System automatically advances the conversation when eachsubtitle's cutscene sequence is finished. If you want to require the player toclick a "continue" button to manually advance the conversation, followthese steps:
1.Inyour UI, add continue buttons to the NPC and/or PC subtitle panels.
2.Assignthose buttons to the Continue Button properties on the UI component.
3.Inthe Dialogue Manager's Display Settings, select an option for Continue Button otherthan Never.
Most ofthe built-in prefabs do not have continue buttons. However, you can make a copyof them and add your own continue button if desired.
Tomanually simulate a click of the continue button, send"OnConversationContinue" to the Dialogue Manager. Example:
字幕继续按钮
默认情况下,对话系统自动地使谈话时,每个字幕动画序列的完成。如果你想要求玩家点击“继续”按钮手动推进对话,遵循这些步骤:
1。你的UI添加按钮,继续向全国人民代表大会和/或PC字幕板。
2。将这些按钮继续按钮属性的UI组件。
3。在对话管理器的显示设置,选择一个选项比其他没有继续按钮。
大多数的内置预设没有继续按钮。然而,你可以复制他们,如果需要继续添加您自己的按钮。
手动模拟点击继续按钮,发送“onconversationcontinue”的对话管理器。的例子:
QuestMessages
Questlog windows broadcast these messages to the Dialogue Manager when the playertoggles quest tracking. You can add a script to the Dialogue Manager object (ora child object) that handles the message – for example, turning on a gameplayHUD.
•OnQuestTrackingEnabled(string questTitle):Sent when tracking is enabled.
•OnQuestTrackingDisabled(string questTitle):Sent when tracking is disabled or a quest is abandoned.
You canset watches on quest states using QuestLog.AddQuestStateObserver(). See SettingQuest State Observers for more details.
任务信息
任务日志窗口播放这些消息的对话经理当玩家切换任务跟踪。您可以添加一个脚本的对话管理器对象(或子对象)处理消息–例如,打开游戏界面。
?onquesttrackingenabled(字符串questtitle):发送跟踪时启用。
?onquesttrackingdisabled(字符串questtitle):发送跟踪时被禁用或任务是被遗弃的。
你可以设置表上使用questlog addqueststateobserver()任务状态。详情请参阅设置任务的状态观测器。
LuaMessages
You canalso set watches on Lua expressions using DialogueManager.AddLuaObserver(). SeeLua In Scripts for more details, including performance considerations.
Lua的消息
你也可以设置表在Lua dialoguemanager addluaobserver()表达式中使用。详情请参阅脚本LUA,包括性能的考虑。
IsDialogueEntryValidDelegate
Normally,you add conditions on a dialogue entry using its Conditions field, specified inLua. However, if you need to perform extra checking outside of Lua, you can setthe Dialogue Manager's IsDialogueEntryValid delegate. This is a C# method thatreturns true or false.
Example:
isdialogueentryvalid代表
通常,你加上使用条件领域对话的准入条件,指定在Lua中。然而,如果你需要进行额外的检查在Lua中,你可以设置对话经理的isdialogueentryvalid代表。这是一个C #方法返回true或false。
的例子:
Here'sa real world example of 'IsDialogueEntryValid". It's in a subclass ofUnityDialogueUI, but you could put it anywhere. This class just happened to bea good place for this developer.
•The Start() method registers the delegate IsSpeakerNearby().
•Whenever the Dialogue System considers using adialogue entry, it calls this delegate. If it returns true, the entry is keptin consideration. If it returns false, the entry is rejected.
•In this example, IsSpeakerNearby() examinesthe entry's Actor ID. If the actor isn't close enough to the player, it returnsfalse. The functions to check distance aren't shown in this example.
这是一个“isdialogueentryvalid”的真实世界的例子。它在unitydialogueui子类,但你可以把它放在任何地方。这个类只是碰巧这一开发商的好地方。
?该start()方法注册代表isspeakernearby()。
?每当对话系统考虑使用对话进入,它调用此委托。如果返回true,进入保存在考虑。如果返回false,则拒绝入境。
?在这个例子中,isspeakernearby()检查输入的ID。如果演员的演员不是足够接近的玩家,则返回false。功能检查距离不是这个例子所示。
PlayMakerSupport
this pagedescribes integration support for Hutong Games' PlayMaker.
本页描述集成支持奥运会的组织者胡同。
PlayMaker Events
The Dialogue System Events To PlayMaker component (accessible via Window> Dialogue System > Components > PlayMaker > Dialogue SystemEvents) can be added to an object, usually the Dialogue Manager object, to passDialogue System notification messages such as OnConversationStart andOnConversationEnd to FSMs. The full list of messages is in the Conversation,Bark, and Sequence Messages section.
You can also use the sequencer command FSMEvent() to send events fromsequences to FSMs.
组织者的事件
对话系统事件的组织者组件(可以通过窗口> > > >对话系统组件中场对话系统事件)可以被添加到一个对象,通常的对话管理器对象,通过对话系统通知消息,如onconversationstart和onconversationend到FSM。消息的完整列表在会话,树皮,和序列信息段。
你也可以用音序器命令fsmevent()从序列发送事件到FSM。
PlayMaker Actions
The Dialogue System provides the following PlayMaker actions, listedunder Dialogue System in PlayMaker's Action Browser.
球员的行动
对话系统提供以下的进攻行动,列在中场的行动浏览器对话系统。
Conversation Actions
•Is Conversation Active: Checkswhether a conversation is currently active.
•Start Conversation: Starts aconversation.
•Stop Conversation: Stops thecurrently-active conversation.
•Does Conversation Have ValidEntries: Checks whether a conversation currently has any valid entriesbranching from the start entry. (If all entries have conditions, it's possiblethat those conditions may all be false at the moment.)
•Update Responses: Updates theresponses for the current state of the active conversation. If the responsemenu entries' conditions have changed while the response menu is being shown,use this to update the response menu.
•Set Portrait: Similar to theSetPortrait() sequencer command, this action overrides an actor's portraitimage.
会话的行为
?对话活动:检查是否是目前活跃的谈话。
?开始谈话:启动一个会话。
?停止:停止当前活动的会话的会话。
?是否有有效的对话条目:检查是否有任何对话目前有效项分支从一开始进入。(如果所有的条目有条件,它是可能的,这些条件都可能是虚假的时刻。)
?更新对策:更新的活动会话的当前状态的反应。如果响应菜单项的条件,而响应菜单被显示的改变,使用此更新响应菜单。
?设定肖像:类似于setportrait()音序器的命令,这个动作演员的肖像图像覆盖。
Bark Actions
•Bark: Makes a character bark.
树皮的行动
?树皮:使一个字符的树皮。
Sequence Actions
•Is Sequence Playing: Checks whethera sequencer is currently playing.
•Start Sequence: Starts a sequence.
•Stop Sequence: Stops a sequenceimmediately.
动作的顺序
?序列播放:检查是否一个音序器目前正在。
?启动顺序:启动顺序。
?停止序列:序列立即停止。
Alert Actions
•Show Alert: Shows a gameplay alertusing the dialogue UI.
警报措施
?显示警报:警报显示游戏使用对话界面。
Quest Actions
•Add Quest: Adds a quest to thequest table.
•Delete Quest: Deletes a quest fromthe quest table.
•Get Quest Description: Gets thedescription text of a quest.
•Get Quest State: Gets the state ofa quest.
•Set Quest State: Sets the state ofa quest.
•Get Quest Entry Count: Gets the numberof quest entries (sub-quests) in a quest.
•Add Quest Entry: Adds an entry to aquest.
•Get Quest Entry: Gets thedescription of a quest entry.
•Get Quest Entry State: Gets thestate of a quest entry.
•Set Quest Entry State: Sets thestate of a quest entry.
•Is Quest Abandonable: Checkswhether a quest is abandonable.
•Is Quest Tracking Enabled: Checkswhether tracking is enabled on a quest.
•Set Quest Tracking: Sets trackingon or off on a quest.
•Get Quest Abandon Sequence: Getsthe quest's Abandon Sequence (if defined).
探索行动
?添加任务:增加了一个探索任务表。
?删除:删除任务从任务表任务。
?把任务描述:获取任务描述文本。
?得到任务的状态:获取任务状态。
?设置任务的状态:设置一个任务状态。
?把任务进入计数:获取任务项数(子任务)在一个任务。
?添加任务输入:将项添加到任务。
?把任务条目:获取任务项的描述。
?把任务进入状态:获取任务进入状态。
?设置任务进入状态:设置一个任务进入状态。
?是放弃追求:检查是否是放弃追求。
?是追求跟踪检查是否启用:启用跟踪是一个追求。
?设置跟踪:跟踪任务设置或关闭一个任务。
?把任务放弃序列:获取任务放弃序列(如果定义)。
Status and Relationship Actions
•Set Status: Sets the status that isdefined between any two assets, which is referred to as a mutual status.
•Get Status: Gets the mutual statusdefined between any two assets.
•Set Relationship: Sets thenumerical relationship value between any two actors. Relationships can beuseful for controlling NPC responses based on a relationship value.
•Get Relationship: Gets therelationship value between two actors.
•Inc Relationship: Increments therelationship value between two actors.
•Dec Relationship: Decrements therelationship value between two actors.
措施的状况和关系
?设置状态:设置状态,是指任何两种资产之间,这被称为一个共同的状态。
?获取状态:被定义的任何两种资产之间的相互地位。
?集关系:设置任何两个演员之间的数值关系价值。关系可以控制NPC反应基于关系价值是有用的。
?得到的关系:有两个演员间的关系价值。
?公司的关系:增量的关系价值之间的两个演员。
?12月的关系:递减关系价值之间的两个演员。
Save & Load Actions
•Apply Persistent Data: Appliespersistent data from the Lua environment to the objects in the scene.
•Apply Savegame Data: Appliessavegame data to the Lua environment and the scene.
•Record Persistent Data: Tellsobjects in the scene to record persistent data into the Lua environment.
•Record Savegame Data: Recordspersistent data and extracts it as savegame data.
•Reset Persistent Data: Clearspersistent data in the Lua environment.
•Broadcast Level Will Be Unloaded:If you use Persistent Destructible or Increment On Destroy components, use thisaction before loading a new level. This tells the components to ignore theirdestruction due to the level change.
保存和加载的行动
?应用:适用于持久数据持久性数据从lua环境场景中的物体。
?应用:适用于存档数据存档数据,lua环境和场景。
?记录数据持久性:对场景中的对象持久化数据到Lua环境记录。
?记录:记录存档数据的持久化数据提取它作为存档资料。
?重置数据持久性:清除Lua环境中的持久性数据。
?广播级将卸载:如果你使用持续性破坏或摧毁组件增量加载一个新的水平,在使用这个动作。这告诉成分忽视他们的破坏水平的变化。
DatabaseActions
•Add Dialogue Database: Adds a dialoguedatabase to the Dialogue Manager's master database.
•Remove Dialogue Database: Removes a dialoguedatabase from the Dialogue Manager's master database.
•Reset Dialogue Database: Resets the DialogueManager's master database to an initial state.
•Set Default Dialogue Database: Sets thedefault database to use for the Dialogue Manager's master database.
•PreloadMasterDatabase: Normally the masterdatabase is loaded just before being used by the first conversation, bark, orquest update. Use this action to load it immediately.
•PreloadDialogueUI: Normally the dialogue UI isloaded just before being used for the first time. Use this action to load itimmediately.
数据库操作
?添加对话数据库:添加一个对话的对话管理数据库的主数据库。
?删除:删除对话数据库从对话经理的主数据库对话数据库。
?重置:重置数据库对话对话管理器的主数据库的初始状态。
?设置默认的对话:数据库设置用于对话管理器的主数据库的默认数据库。
?preloadmasterdatabase:通常主数据库是在被第一次谈话,树皮用来加载,或追求更新。用这个动作来加载它立即。
?preloaddialogueui:通常对话UI之前被用于第一次加载。用这个动作来加载它立即。
Lua /Internal Data Actions
•Run Lua: Runs arbitrary Lua code.
•Get Variable: Gets the value of a variable inthe Lua Variable[] table.
•Set Variable: Sets the value of a variable inthe Lua Variable[] table.
•Get Lua Field: Gets the value of a field of anelement in a Lua table (Actor[], Item[], or Location[]).
•Set Lua Field: Sets the value of a field of anelement in a Lua table (Actor[], Item[], or Location[]).
Lua /内部数据的行为
?运行:运行任意Lua Lua代码。
?获取变量:获取在Lua变量[ ]表变量的值。
?设置变量:套在Lua变量[ ]表变量的值。
?得到Lua领域:得到一场在Lua表中的一个元素的值(演员[ ],[ ]项,或位置[ ])。
?集Lua场:设置字段在Lua表的一个元素的值(演员[ ],[ ]项,或位置[ ])。
Using LuaActions
Thissection describes how to use actions to access data in the Dialogue System'sLua environment.
TheVariable[] table is one-dimensional. That is, every variable (such asVariable["Actor"]) has only one value.Variable["Actor"].Age isn't valid. Variable["Actor"] andVariable["Conversant"] are string values. Variable["Actor"]contains the name of the actor in the current conversation, andVariable["Conversant"] contains the name of the conversant.
TheActor[], Item[]/Quest[], and Location[] tables are two-dimensional. Everyentry, such as Actor["Player"] has a number of fields such asActor["Player"].Age.
Let'ssay you know the name of an actor ("Fred"), and you want to get hisage. In the Dialogue System's Lua environment, this is stored in Actor["Fred"].Age,and this is what you'll use in the Dialogue Editor in Conditions and Scriptfields.
InPlayMaker, you can use the Get Lua Field action. Select the Actor Table andmanually enter "Fred" as the element and "Age" as theField. In the example below, the result is stored in a float variable named"Freds Age".
使用Lua动作
本节描述如何使用行动在对话系统的Lua环境数据访问。
可变[ ]表是一维的。那就是,每一个变量(如变量[“演员”])只有一个值。变量[“演员”]年龄不是有效的。变量[“演员”]和[ ]是变“精通”的字符串值。变量[“演员”]包含名字的演员在当前会话,和可变[“精通”]包含了熟悉的。
演员[ ],[ ]项目/任务[ ],[ ]表是二维的位置。每一个条目,如演员[“玩家”]有许多领域如演员[ ]时代“玩家”。
让我们假设你知道一个演员的名字(“弗莱德”),和你想得到他的年龄。在对话系统的Lua环境,这是存储在演员[弗莱德]。年龄,这是你会用在对话的条件和脚本编辑域。
在中场,你可以使用得到Lua场作用。选择演员表,手动输入“弗莱德”的元素和“年龄”的领域。在下面的例子中,结果被存储在一个浮点变量命名为“弗莱德的时代”。
Ifyou're in the middle of a conversation and you don't know ahead of time who theactor is, you can first get the value Variable["Actor"] by using theGet Variable action. In the example below, it's stored in a string variablenamed "Current Actor Name". Then you can provide the stringvariable's value to the Get Lua Field action.
如果你在谈话中你不提前的演员是谁知道,你可以先用得到的可变作用得到的值的变量[演员]。在下面的例子中,它是储存在一个字符串变量命名为“当前的演员的名字”。然后你可以提供的字符串变量的值到Lua场作用。
The SetLua Field and Set Variable actions work similarly but come with one importantcaveat. Lua is essentially typeless. You can assign a number toActor["Fred"].Age, and then you can turn around and assign a stringto it. Of course, a string probably wouldn't make sense in context, but in Luayou can still do it if you want. The PlayMaker action will assign any/allvalues that you've specified. In the example below, to prevent the action fromtrying to assign a string or bool value, the string and bool properties havebeen set to "None" by clicking the little button to the right of eachone.
设定Lua场和设置变量的操作同样是一个重要的警告。Lua是无类型。你可以指定一个数字演员[弗莱德]。年龄,然后你可以转身,把一个字符串赋给它。当然,一个字符串可能不会使语境中的意义,但在Lua中你仍然可以做你想做的吧。球员的动作会分配任何/所有的值所指定的。在下面的示例中,为了防止行动,试图将一个字符串或布尔值,字符串和布尔属性被设置为“无”,单击小按钮,每一项权利。
There'sone more thing to note about Lua in the Dialogue System: spaces (' ') andhyphens ('-') in indices are replaced by underscores ('_'). So in yourConditions and Script fields, you should useVariable["Another_Variable"]. (Note the underscore.)
还有一件事要注意在对话系统关于Lua:空间(”)和连字符(“”)在指数由下划线('_’)。所以在你的条件和脚本的领域,你应该使用变量[“another_variable”]。(注意下划线。)
plyGame Support
Thispage describes integration support for PL Young's plyGame and plyBlox.
本页描述了PL年轻的plygame和plyblox集成支持。
ExampleScene
TheplyGame support package includes an example scene. You cannot import theexample into an existing project as it will override all your plyData. Theexample must be run in a new project. The example is useful to study tounderstand how the Dialogue System integrates with plyGame. Then you canincorporate the same functionality into your own plyGame project.
示例场景
该plygame支持包中包含的一个例子的场景。无法导入到现有的项目实例,它将覆盖所有你的plydata。例必须运行在一个新的项目。这个例子是为了了解对话系统集成plygame研究有用。然后你可以将同样的功能集成到您自己的plygame项目。
本篇到这里,下篇我们继续,虽然是把以前的东西贴上来,但是一篇也要花1个半小时,真的有点晕了。。。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。