Beispiel #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);
        }
Beispiel #2
0
 public QD_ConnectionRule(QD_NodeType inputType, int inputID, QD_NodeType outputType, int outputID)
 {
     InputType  = inputType;
     InputID    = inputID;
     OutputType = outputType;
     OutputID   = outputID;
 }
Beispiel #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;
         }
     }
 }
 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)
     };
 }
 /// <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;
     }
 }
Beispiel #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);
        }
Beispiel #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;
 }
Beispiel #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;
 }
 /// <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;
     }
 }
Beispiel #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;
                }
            }
        }
Beispiel #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;
     }
 }
Beispiel #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;
             }
         }
     }
 }
Beispiel #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);
     }
 }
 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>
     {
     };
 }
 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)
     };
 }
Beispiel #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)
     };
 }
Beispiel #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;
         }
     }
 }
Beispiel #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);
        }
        /// <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;
                }
            }
        }
Beispiel #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);
        }
 /// <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);
 }
 /// <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);
 }
Beispiel #23
0
 public QD_MessageInfo(int id, int nextID, QD_NodeType type)
 {
     ID     = id;
     NextID = nextID;
     Type   = type;
 }
Beispiel #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);
 }
Beispiel #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)
 {
 }