Unity Plugin Plygame Tutorial: Diaq Dialogue System

Source: Internet
Author: User

This article for the Lone Moon Blue Wind written, reproduced please indicate the source:http://fengyu.name/?cat=game&id=296

Diaq is a dialogue and mission system under the umbrella of Plygame. With a visual dialogue and Task Editor, it is easy to handle conversations and tasks. But the official document is not to force, after a general study, will finally use a simple dialogue system, share to everyone.

First of all, you need to install the Diaq plugin, Diaq has a separate, but also included in the Plygame, as for where there are "sell", please use the great search engine.

After installing the Diaq plugin, the menu bar will appear with the Diaq menu in Windows, and there will be a pl young menu in tools with Diaq below.

We open the Diagraphs editor,Tools > PL Young > DiaQ > Graph Editor。

The icons are left to right: Add, delete, move up, move down, modify names, open task Editor, settings, help documentation.

We click Add, add an item to the list, and then we can create the dialogue and process in the right window. Select a conversation in the list on the left, and the toolbar to the left will appear at the top right.

From left to right: conditional judgment, send message (SendMessage event), set variable value, wait, debug, Task reward, complete task, task status, dialog.

In this article, we only talk about the last one: dialogue.

Clicking on the dialog icon creates a dialog box in the view below, where the dialog box is selected and the various properties of the current dialog box are displayed in Unity's Inspector panel.

Dialogure Text: Conversation content

Responses: dialog options, for example, NPC asks you whether to accept the task, can answer "accept" and "reject", each option line, click the plus sign on the right side to add

Linked Quest: Connecting to Tasks

ID: ID of the current dialog box

Custom Ident: Customization ID for the current dialog, type string string

Comment: Note Information to be displayed in the dialog editor for the purpose of the conversation, displayed only in the editor, not displayed in the dialog

Show in Graph: whether the above note information is displayed in the editor

Node MetaData: The data passed by the dialog, where you can pass various types of data for the next conversation to use

Now you can create just a few conversations and connect them together. You can click on the arrow, the connection line appears, and then click the dialogue that needs to connect, two dialog box will be connected by the line.

After all the conversations are complete, you'll Assets / plyData / DiaQ see a diaq prefab in the folder and add it to the game scene.

Next we write the code of the dialogue.

First, you need to:

Using plycommon;using Diaq;

Second, we need to declare a variable that holds the content of the obtained conversation:

Private plygraph conversation = null;

Then in Start , get the conversation content (here you can Ident get through and Name two ways, freely choose):

Conversation = DiaQEngine.Instance.graphManager.GetGraphByIdent (dialogureid.tostring ());

After that, all the conversations are displayed in the GUI, so the code is written in OnGUI :

Determine if there is currently a conversation in Progress if  (DiaQEngine.Instance.graphManager.ActiveGraph ()  == null) {     //Start Dialogue     diaqengine.instance.graphmanager.begingraph (conversation) without dialogue;} else{    //Get Conversation Node     DiaQNode_Dlg dlg =  DiaQEngine.Instance.graphManager.NodeWaitingForData ()  as diaqnode_dlg;    // If the node is not NULL, call content     if  (dlg != null)     {         //Gets the conversation content and assigns a value         string _ text = dlg.dialoguetext;        rect dialogbox =  new rect (0,0,300,300);         gui. Box (dialogbox, _text);         //gets the number of options and loops through all options and outputs the option with a button          _choicescount = dlg.rEsponses. length;        for  (int i = 0; i <  _choicescount; i++)         {             //dlg.responses[i] The content text for the option              if  (GUI. Button (New rect (0, i * 45),  100, 50),  dlg.responses[i])              {                 //jump to the next connected conversation according to the options                  diaqengine.instance.graphmanager.senddatatonode (i);             }         }    }}

In this way, we create and invoke a dialog that is made using Diaq.

This article for the Lone Moon Blue Wind written, reproduced please indicate the source:http://fengyu.name/?cat=game&id=296

Unity Plugin Plygame Tutorial: Diaq Dialogue System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.