Пример #1
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);
        }
Пример #2
0
 public QD_ConnectionRule(QD_NodeType inputType, int inputID, QD_NodeType outputType, int outputID)
 {
     InputType  = inputType;
     InputID    = inputID;
     OutputType = outputType;
     OutputID   = outputID;
 }
Пример #3
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;
         }
     }
 }
Пример #4
0
 public QD_MessageNode(int id, QD_NodeType type, float x = 0, float y = 0) : base(id, type, x, y)
 {
     Type   = QD_NodeType.Message;
     Window = new Rect(0, 0, 200, 175);
     Inputs = new List <QD_Knob>
     {
         new QD_Knob(0, "Speaker", QD_KnobType.Input, 7.5f, false),
         new QD_Knob(1, "Previous", QD_KnobType.Input, 35, false)
     };
     Outputs = new List <QD_Knob>
     {
         new QD_Knob(0, "Speaker", QD_KnobType.Output, 7.5f),
         new QD_Knob(1, "Next", QD_KnobType.Output, 35, false)
     };
     AllowedInputs = new List <QD_ConnectionRule>
     {
         new QD_ConnectionRule(QD_NodeType.Message, 0, QD_NodeType.Speaker, 0),
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Conversation, 0),
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Choice, 0)
     };
     AllowedOutputs = new List <QD_ConnectionRule>
     {
         new QD_ConnectionRule(QD_NodeType.Message, 0, QD_NodeType.Message, 0),
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 0, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 1, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 2, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 3, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 4, QD_NodeType.Message, 1),
         new QD_ConnectionRule(QD_NodeType.Choice, 5, QD_NodeType.Message, 1)
     };
 }
Пример #5
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID)
 {
     if (FirstMessage == connectionID)
     {
         FirstMessage = -1;
     }
 }
Пример #6
0
        /// <summary>
        /// Returns whether or not a connection is allowed. Used before connecting.
        /// </summary>
        /// <param name="knobType">The knob type being connected to on this node.</param>
        /// <param name="knobID">The id of the knob being connected to on this node.</param>
        /// <param name="otherNodeType">The node type being connected to on the other node.</param>
        /// <param name="otherKnobType">The knob type being connected to on the other node.</param>
        /// <param name="otherKnobID">The id of the knob being connected to on the other node.</param>
        /// <returns></returns>
        public bool CanConnect(QD_KnobType knobType, int knobID, QD_NodeType otherNodeType, QD_KnobType otherKnobType, int otherKnobID)
        {
            bool canConnect = false;

            if (knobType == QD_KnobType.Input)
            {
                foreach (var rule in AllowedInputs)
                {
                    if (rule.InputType == Type && rule.InputID == knobID && rule.OutputType == otherNodeType && otherKnobType == QD_KnobType.Output && rule.OutputID == otherKnobID)
                    {
                        canConnect = true;
                        break;
                    }
                }
            }
            else if (knobType == QD_KnobType.Output)
            {
                foreach (var rule in AllowedOutputs)
                {
                    if (rule.OutputType == Type && rule.OutputID == knobID && rule.InputType == otherNodeType && otherKnobType == QD_KnobType.Input && rule.InputID == otherKnobID)
                    {
                        canConnect = true;
                        break;
                    }
                }
            }

            return(canConnect);
        }
Пример #7
0
 public QD_Node(int id, QD_NodeType type, float x = 0, float y = 0)
 {
     ID       = id;
     Type     = type;
     Window.x = x;
     Window.y = y;
 }
Пример #8
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 (knobID >= NextMessages.Count)
     {
         return;
     }
     NextMessages[knobID] = connectionID;
 }
Пример #9
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)
     {
     }
     else if (knobType == QD_KnobType.Output)
     {
         FirstMessage = connectionID;
     }
 }
Пример #10
0
        /// <summary>
        /// The function called to modify the node's data whenever a node disconnects.
        /// </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 connected node.</param>
        public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID)
        {
            int count = NextMessages.Count;

            for (int i = 0; i < count; ++i)
            {
                if (NextMessages[i] == connectionID)
                {
                    NextMessages[i] = -1;
                }
            }
        }
Пример #11
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID)
 {
     if (Speaker == connectionID)
     {
         SpeakerName = "";
         Speaker     = -1;
     }
     if (PreviousMessage == connectionID)
     {
         PreviousMessage = -1;
     }
     if (NextMessage == connectionID)
     {
         NextMessage = -1;
     }
 }
Пример #12
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 /// <param name="knobID">The id of the knob.</param>
 /// <param name="knobType">The type of the knob.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int knobID, QD_KnobType knobType)
 {
     if (knobID >= NextMessages.Count)
     {
         return;
     }
     if (knobType == QD_KnobType.Output)
     {
         int count = NextMessages.Count;
         for (int i = 0; i < count; ++i)
         {
             if (NextMessages[i] == connectionID)
             {
                 NextMessages[i] = -1;
             }
         }
     }
 }
Пример #13
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 /// <param name="connectionKnobID">The id of the connected knob.</param>
 /// <param name="knobID">The id of the knob.</param>
 /// <param name="knobType">The type of the knob.</param>
 public virtual void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QD_KnobType knobType)
 {
     if (Type == QD_NodeType.Speaker)
     {
         QD_DialogueEditor.db.GetSpeakerNode(ID).OnDisconnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
     }
     else if (Type == QD_NodeType.Message)
     {
         QD_DialogueEditor.db.GetMessageNode(ID).OnDisconnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
     }
     else if (Type == QD_NodeType.Conversation)
     {
         QD_DialogueEditor.db.GetConversationNode(ID).OnDisconnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
     }
     else if (Type == QD_NodeType.Choice)
     {
         QD_DialogueEditor.db.GetChoiceNode(ID).OnDisconnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
     }
 }
Пример #14
0
 public QD_ChoiceNode(int id, QD_NodeType type, float x = 0, float y = 0) : base(id, type, x, y)
 {
     Type   = QD_NodeType.Speaker;
     Window = new Rect(0, 0, 300, 65);
     Inputs = new List <QD_Knob>
     {
         new QD_Knob(0, "Previous Messages", QD_KnobType.Input, 7.5f, false)
     };
     Outputs = new List <QD_Knob>
     {
     };
     AllowedInputs = new List <QD_ConnectionRule>
     {
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Choice, 0)
     };
     AllowedOutputs = new List <QD_ConnectionRule>
     {
     };
 }
Пример #15
0
 public QD_SpeakerNode(int id, QD_NodeType type, float x = 0, float y = 0) : base(id, type, x, y)
 {
     Type   = QD_NodeType.Speaker;
     Window = new Rect(0, 0, 200, 110);
     Inputs = new List <QD_Knob>
     {
     };
     Outputs = new List <QD_Knob>
     {
         new QD_Knob(0, "Messages", QD_KnobType.Output, 40)
     };
     AllowedInputs = new List <QD_ConnectionRule>
     {
     };
     AllowedOutputs = new List <QD_ConnectionRule>
     {
         new QD_ConnectionRule(QD_NodeType.Message, 0, QD_NodeType.Speaker, 0)
     };
 }
Пример #16
0
 public QD_ConversationNode(int id, QD_NodeType type, float x = 0, float y = 0) : base(id, type, x, y)
 {
     Type   = QD_NodeType.Conversation;
     Window = new Rect(0, 0, 200, 65);
     Inputs = new List <QD_Knob>
     {
     };
     Outputs = new List <QD_Knob>
     {
         new QD_Knob(0, "First Message", QD_KnobType.Output, 40, false)
     };
     AllowedInputs = new List <QD_ConnectionRule>
     {
     };
     AllowedOutputs = new List <QD_ConnectionRule>
     {
         new QD_ConnectionRule(QD_NodeType.Message, 1, QD_NodeType.Conversation, 0)
     };
 }
Пример #17
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 /// <param name="knobID">The id of the knob.</param>
 /// <param name="knobType">The type of the knob.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int knobID, QD_KnobType knobType)
 {
     if (knobType == QD_KnobType.Input)
     {
         if (knobID == 0 && Speaker == connectionID)
         {
             SpeakerName = "";
             Speaker     = -1;
         }
         if (PreviousMessage == connectionID && knobID == 1)
         {
             PreviousMessage = -1;
         }
     }
     else if (knobType == QD_KnobType.Output)
     {
         if (NextMessage == connectionID && knobID == 1)
         {
             NextMessage = -1;
         }
     }
 }
Пример #18
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);
        }
Пример #19
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 override void OnConnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QD_KnobType knobType)
        {
            Data.OnConnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
            QD_DialogueEditor.db.DataDB.SetMessage(Data.ID, Data);

            if (connectionType == QD_NodeType.Speaker && knobID == 0 && knobType == QD_KnobType.Input)
            {
                QD_Node    message       = QD_DialogueEditor.db.GetNode(ID);
                QD_Knob    messageKnob   = message.GetKnob(QD_KnobType.Output, 0);
                int        nextMessageID = messageKnob.Connections.Count > 0 ? messageKnob.Connections.keys[0] : -1;
                QD_Message nextMessage   = nextMessageID != -1 ? dialogue.GetMessage(nextMessageID) : null;
                while (nextMessageID != -1 && nextMessage != null)
                {
                    nextMessage.Speaker     = connectionID;
                    nextMessage.SpeakerName = dialogue.GetSpeaker(connectionID).Name;
                    QD_DialogueEditor.db.DataDB.SetMessage(nextMessage.ID, nextMessage);

                    message       = QD_DialogueEditor.db.GetNode(nextMessageID);
                    messageKnob   = message.GetKnob(QD_KnobType.Output, 0);
                    nextMessageID = messageKnob.Connections.Count > 0 ? messageKnob.Connections.keys[0] : -1;
                    nextMessage   = nextMessageID != -1 ? dialogue.GetMessage(nextMessageID) : null;
                }
            }
        }
Пример #20
0
        /// <summary>
        /// Creates a new node of the given type at the given position.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="position"></param>
        public void CreateNode(QD_NodeType type, Vector2 position)
        {
            int id   = NextID++;
            var node = new QD_Node(id, type, position.x, position.y);

            if (type == QD_NodeType.Speaker)
            {
                var speakerNode = new QD_SpeakerNode(id, type, position.x, position.y);

                node.Window.width   = speakerNode.Window.width;
                node.Window.height  = speakerNode.Window.height;
                node.Inputs         = speakerNode.CloneKnobs(QD_KnobType.Input);
                node.Outputs        = speakerNode.CloneKnobs(QD_KnobType.Output);
                node.AllowedInputs  = speakerNode.AllowedInputs;
                node.AllowedOutputs = speakerNode.AllowedOutputs;

                var speakerData = new QD_Speaker(id);
                DataDB.Speakers.Add(speakerData);
                speakerNode.Data = speakerData;

                SpeakerNodes.Add(speakerNode);
            }
            else if (type == QD_NodeType.Message)
            {
                var messageNode = new QD_MessageNode(id, type, position.x, position.y);

                node.Window.width   = messageNode.Window.width;
                node.Window.height  = messageNode.Window.height;
                node.Inputs         = messageNode.CloneKnobs(QD_KnobType.Input);
                node.Outputs        = messageNode.CloneKnobs(QD_KnobType.Output);
                node.AllowedInputs  = messageNode.AllowedInputs;
                node.AllowedOutputs = messageNode.AllowedOutputs;

                var messageData = new QD_Message(id);
                DataDB.Messages.Add(messageData);
                messageNode.Data = messageData;

                MessageNodes.Add(messageNode);
            }
            else if (type == QD_NodeType.Conversation)
            {
                var conversationNode = new QD_ConversationNode(id, type, position.x, position.y);

                node.Window.width   = conversationNode.Window.width;
                node.Window.height  = conversationNode.Window.height;
                node.Inputs         = conversationNode.CloneKnobs(QD_KnobType.Input);
                node.Outputs        = conversationNode.CloneKnobs(QD_KnobType.Output);
                node.AllowedInputs  = conversationNode.AllowedInputs;
                node.AllowedOutputs = conversationNode.AllowedOutputs;

                var conversationData = new QD_Conversation(id);
                DataDB.Conversations.Add(conversationData);
                conversationNode.Data = conversationData;

                ConversationNodes.Add(conversationNode);
            }
            else if (type == QD_NodeType.Choice)
            {
                var choiceNode = new QD_ChoiceNode(id, type, position.x, position.y);

                node.Window.width   = choiceNode.Window.width;
                node.Window.height  = choiceNode.Window.height;
                node.Inputs         = choiceNode.CloneKnobs(QD_KnobType.Input);
                node.Outputs        = choiceNode.CloneKnobs(QD_KnobType.Output);
                node.AllowedInputs  = choiceNode.AllowedInputs;
                node.AllowedOutputs = choiceNode.AllowedOutputs;

                var choiceData = new QD_Choice(id);
                DataDB.Choices.Add(choiceData);
                choiceNode.Data = choiceData;

                ChoiceNodes.Add(choiceNode);
            }

            Nodes.Add(node);
        }
Пример #21
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 /// <param name="connectionKnobID">The id of the connected knob.</param>
 /// <param name="knobID">The id of the knob.</param>
 /// <param name="knobType">The type of the knob.</param>
 public override void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QD_KnobType knobType)
 {
     Data.OnDisconnect(dialogue, connectionType, connectionID, connectionKnobID, knobID, knobType);
     QD_DialogueEditor.db.DataDB.SetChoice(Data.ID, Data);
 }
Пример #22
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 public override void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID)
 {
     Data.OnDisconnect(dialogue, connectionType, connectionID);
     QD_DialogueEditor.db.DataDB.SetMessage(Data.ID, Data);
 }
Пример #23
0
 public QD_MessageInfo(int id, int nextID, QD_NodeType type)
 {
     ID     = id;
     NextID = nextID;
     Type   = type;
 }
Пример #24
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 /// <param name="connectionKnobID">The id of the connected knob.</param>
 /// <param name="knobID">The id of the knob.</param>
 /// <param name="knobType">The type of the knob.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID, int connectionKnobID, int knobID, QD_KnobType knobType)
 {
     OnDisconnect(dialogue, connectionType, connectionID, knobID, knobType);
 }
Пример #25
0
 /// <summary>
 /// The function called to modify the node's data whenever a node disconnects.
 /// </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 connected node.</param>
 public void OnDisconnect(QD_Dialogue dialogue, QD_NodeType connectionType, int connectionID)
 {
 }