Beispiel #1
0
 /// <summary>
 /// The function called to modify the node's data whenever a node connects.
 /// </summary>
 /// <param name="dialogue">The dialogue data.</param>
 /// <param name="connectionType">The type of the connecting node.</param>
 /// <param name="connectionID">The id of the connecting node.</param>
 /// <param name="connectionKnobID">The id of the connecting knob.</param>
 /// <param name="knobID">The id of this node's knob.</param>
 /// <param name="knobType">The type of this node's knob.</param>
 public void OnConnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QD_KnobType knobType)
 {
     if (knobType == QD_KnobType.Input)
     {
         if (connectionKnobID == 0 && knobID == 0)
         {
             if (connectionType == QD_NodeType.Speaker)
             {
                 QD_Speaker speaker = dialogue.GetSpeaker(connectionID);
                 Speaker     = speaker.ID;
                 SpeakerName = speaker.Name;
             }
             else if (connectionType == QD_NodeType.Message)
             {
                 QD_Message message = dialogue.GetMessage(connectionID);
                 Speaker     = message.Speaker;
                 SpeakerName = message.SpeakerName;
             }
         }
         else if (PreviousMessage != connectionID && connectionKnobID == 1 && knobID == 1)
         {
             PreviousMessage = connectionID;
         }
     }
     else if (knobType == QD_KnobType.Output)
     {
         if (NextMessage != connectionID && knobID == 1)
         {
             NextMessage = connectionID;
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Goes to the next message and returns its ID and type. Base if there is no next message, but otherwise Message or Choice.
        /// </summary>
        /// <param name="choice">The choice, if the current message is a choice. By default -1, meaning the current node is a message node.</param>
        /// <returns></returns>
        public QD_MessageInfo NextMessage(int choice = -1)
        {
            if (currentMessageInfo.NextID < 0 && choice == -1)
            {
                currentMessageInfo = new QD_MessageInfo(-1, -1, QD_NodeType.Base);
                return(currentMessageInfo);
            }

            QD_NodeType type   = GetMessageType(currentMessageInfo.NextID);
            int         id     = -1;
            int         nextID = -1;

            if (currentMessageInfo.Type == QD_NodeType.Message)
            {
                id = currentMessageInfo.NextID;

                if (type == QD_NodeType.Message && id >= 0)
                {
                    QD_Message m = dialogue.GetMessage(id);
                    nextID = m.NextMessage;
                }
            }
            else if (currentMessageInfo.Type == QD_NodeType.Choice && choice >= 0)
            {
                QD_Choice c = dialogue.GetChoice(currentMessageInfo.ID);
                currentMessageInfo.NextID = c.NextMessages[choice];
                id   = currentMessageInfo.NextID;
                type = QD_NodeType.Message;
                QD_Message m = dialogue.GetMessage(id);
                nextID = m.NextMessage;
            }

            currentMessageInfo = new QD_MessageInfo(id, nextID, type);
            return(currentMessageInfo);
        }
Beispiel #3
0
        /// <summary>
        /// Returns the id of the next message.
        /// </summary>
        /// <param name="id">The ID of the current message.</param>
        /// <param name="choice">The choice, if the current message is a choice. By default -1, meaning the current node is a message node.</param>
        /// <returns></returns>
        public int GetNextID(int id, int choice = -1)
        {
            int         nextID = -1;
            QD_NodeType type   = GetMessageType(id);

            if (type == QD_NodeType.Message)
            {
                QD_Message m = dialogue.GetMessage(id);
                if (m.NextMessage >= 0)
                {
                    nextID = m.NextMessage;
                }
            }
            else if (type == QD_NodeType.Conversation)
            {
                QD_Choice c = dialogue.GetChoice(id);
                if (c.NextMessages[choice] >= 0)
                {
                    nextID = c.NextMessages[choice];
                }
            }
            return(nextID);
        }
Beispiel #4
0
 /// <summary>
 /// Sets a message with the given id.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="message"></param>
 /// <returns></returns>
 public void SetMessage(int id, QD_Message message)
 {
     Messages[GetMessageIndex(id)] = message;
 }