Ejemplo n.º 1
0
        //Return the linetobreak from the rpgtalknode after it
        public string GetFollowUpTalkBreak()
        {
            foreach (ConnectionPort port in connectionPorts)
            {
                if (port.direction == Direction.Out && port.connections.Count > 0)
                {
                    RPGTalkNode node = (port.connections[0].body as RPGTalkNode);
                    if (node.attachedToChoice == null || node.attachedToChoice == this)
                    {
                        return(node.CutsceneTitle);
                    }
                    else
                    {
                        RPGTalkNode initialNode = node;
                        while (true)
                        {
                            if (initialNode.attachedTo == null)
                            {
                                break;
                            }
                            else
                            {
                                initialNode = initialNode.attachedTo;
                            }
                        }
                        return(initialNode.CutsceneTitle);
                    }
                }
            }

            return("");
        }
Ejemplo n.º 2
0
 protected internal override void OnRemoveConnection(ConnectionPort port, ConnectionPort connection)
 {
     base.OnRemoveConnection(port, connection);
     if (port.direction == Direction.In)
     {
         attachedTo = null;
     }
 }
Ejemplo n.º 3
0
        protected internal override void OnAddConnection(ConnectionPort port, ConnectionPort connection)
        {
            base.OnAddConnection(port, connection);
            if (!(connection.body is RPGTalkNode))
            {
                port.RemoveConnection(connection);
                return;
            }


            if (port.direction == Direction.In)
            {
                attachedTo = connection.body as RPGTalkNode;
            }
        }
Ejemplo n.º 4
0
        protected internal override void OnRemoveConnection(ConnectionPort port, ConnectionPort connection)
        {
            base.OnRemoveConnection(port, connection);
            if (port.direction == Direction.In)
            {
                if (attachedTo == connection.body as RPGTalkNode)
                {
                    if (port.connections.Count == 0)
                    {
                        startOfCutscene = true;
                        attachedTo      = null;
                        CutsceneTitle   = "Cutscene_" + (NodeEditor.curNodeCanvas as RPGTalkNodeCanvas).GetCorrectCutsceneAutoTitle().ToString();
                    }
                    else
                    {
                        attachedTo = port.connections[0].body as RPGTalkNode;
                    }
                }
                else if (attachedToChoice == connection.body as RPGTalkChoiceNode)
                {
                    //removed choice I came from
                    attachedToChoice = null;
                    CutsceneTitle    = "Cutscene_" + (NodeEditor.curNodeCanvas as RPGTalkNodeCanvas).GetCorrectCutsceneAutoTitle().ToString();
                }
                else if (attachedToChoice == connection.body as RPGTalkSaveNode)
                {
                    //removed choice I came from
                    attachedToSave = null;
                    CutsceneTitle  = "Cutscene_" + (NodeEditor.curNodeCanvas as RPGTalkNodeCanvas).GetCorrectCutsceneAutoTitle().ToString();
                }
            }
            else
            {
                //Remove choice
                if (connection.body is RPGTalkChoiceNode)
                {
                    choices.Remove(connection.body as RPGTalkChoiceNode);
                }

                //Remove choice
                if (connection.body is RPGTalkSaveNode)
                {
                    saves.Remove(connection.body as RPGTalkSaveNode);
                }
            }

            (NodeEditor.curNodeCanvas as RPGTalkNodeCanvas).GetNextLineInTxt();
        }
Ejemplo n.º 5
0
        //Return the title from the rpgtalknode after it
        public string GetFollowUpTalkTile()
        {
            foreach (ConnectionPort port in connectionPorts)
            {
                if (port.direction == Direction.Out && port.connections.Count > 0)
                {
                    RPGTalkNode node = (port.connections[0].body as RPGTalkNode);
                    if (node.attachedToChoice == null || node.attachedToChoice == this)
                    {
                        return(node.CutsceneTitle);
                    }
                    else
                    {
                        return(node.lineInTxt.ToString());
                    }
                }
            }

            return("");
        }
Ejemplo n.º 6
0
        public string GetText(int currentLine = -1)
        {
            if (currentLine != -1)
            {
                lineInTxt = currentLine;
            }

            string toReturn = "";

            if (characterID != 0)
            {
                toReturn += characters[characterID] + ":";
            }
            if (expressionID != 0 && expressions != null && expressions.Length > expressionID)
            {
                toReturn += "[expression=" + expressions[expressionID] + "]";
            }
            if (choices.Count > 0)
            {
                //remove empty spaces
                questionID = questionID.Replace(" ", string.Empty);
                toReturn  += "[question=" + questionID + "]";
            }
            DialogLine = DialogLine.Replace("\n", "\\n");
            toReturn  += DialogLine;


            foreach (ConnectionPort port in connectionPorts)
            {
                if (port.direction != Direction.Out)
                {
                    break;
                }

                if (port.connections.Count > 0)
                {
                    if (port.connections[0].body is RPGTalkNode)
                    {
                        RPGTalkNode node = (port.connections[0].body as RPGTalkNode);
                        if (node.attachedTo == this)
                        {
                            toReturn += "\n";
                            if (currentLine != -1)
                            {
                                currentLine++;
                            }
                            toReturn += node.GetText(currentLine);
                        }
                        else
                        {
                            if (node.startOfCutscene)
                            {
                                toReturn += "[newtalk start=" + node.CutsceneTitle + "_begin break=" + node.CutsceneTitle + "_end]";
                            }
                            else
                            {
                                RPGTalkNode initialNode = node;
                                while (true)
                                {
                                    if (initialNode.attachedTo == null)
                                    {
                                        break;
                                    }
                                    else
                                    {
                                        initialNode = initialNode.attachedTo;
                                    }
                                }
                                toReturn += "[newtalk start=" + node.lineInTxt + " break=" + initialNode.CutsceneTitle + "_end]";
                            }

                            toReturn += "\n";
                        }
                    }//is rpgtalknode
                    else if (port.connections[0].body is RPGTalkChoiceNode)
                    {
                        toReturn += "\n";
                        foreach (RPGTalkChoiceNode choice in choices)
                        {
                            toReturn += "[choice]" + choice.DialogLine;

                            if (choice.GetFollowUpTalkTile() != "")
                            {
                                int startchoice;
                                if (int.TryParse(choice.GetFollowUpTalkTile(), out startchoice))
                                {
                                    toReturn += "[newtalk start=" + startchoice.ToString() + " break=" + choice.GetFollowUpTalkBreak() + "_end]";
                                }
                                else
                                {
                                    toReturn += "[newtalk start=" + choice.GetFollowUpTalkTile() + "_begin break=" + choice.GetFollowUpTalkBreak() + "_end]";
                                }
                            }
                            toReturn += "\n";
                        }
                    }// is rpgtalkchoice
                    else
                    {
                        toReturn += "\n";
                        foreach (RPGTalkSaveNode save in saves)
                        {
                            toReturn += "[save ";

                            if (save.GetFollowUpTalkTile() != "")
                            {
                                int startchoice;
                                if (int.TryParse(save.GetFollowUpTalkTile(), out startchoice))
                                {
                                    toReturn += "start=" + startchoice.ToString() + " break=" + save.GetFollowUpTalkBreak() + "_end";
                                }
                                else
                                {
                                    toReturn += "start=" + save.GetFollowUpTalkTile() + "_begin break=" + save.GetFollowUpTalkBreak() + "_end";
                                }
                            }

                            toReturn += " data=" + save.savedData + " mod=" + save.modifier + "]";

                            toReturn += "\n";
                        }
                    } // is save
                }     // connection coun > 0
                else
                {
                    //This is the final node
                    toReturn += "\n";
                }
            }//foreach node
            return(toReturn);
        }
Ejemplo n.º 7
0
        protected internal override void OnAddConnection(ConnectionPort port, ConnectionPort connection)
        {
            base.OnAddConnection(port, connection);
            if (port.direction == Direction.In)
            {
                if (connection.body.isChildOf(this))
                {
                    return;
                }

                if (connection.body is RPGTalkNode)
                {
                    startOfCutscene = false;
                    if (attachedTo == null)
                    {
                        attachedTo    = connection.body as RPGTalkNode;
                        CutsceneTitle = attachedTo.CutsceneTitle;
                    }
                }
                else if (connection.body is RPGTalkChoiceNode)
                {
                    if (attachedToChoice == null)
                    {
                        attachedToChoice = connection.body as RPGTalkChoiceNode;
                    }
                    //I am the result of a choice
                    if (attachedToChoice.attachedTo != null)
                    {
                        CutsceneTitle = "FollowUp_" + attachedToChoice.attachedTo.CutsceneTitle + "_" + attachedToChoice.Title;
                    }
                    else
                    {
                        CutsceneTitle = "FollowUp_" + attachedToChoice.Title;
                    }
                }
                else
                {
                    if (attachedToSave == null)
                    {
                        attachedToSave = connection.body as RPGTalkSaveNode;
                    }
                    //I am the result of a choice
                    if (attachedToSave.attachedTo != null)
                    {
                        CutsceneTitle = "FollowUp_" + attachedToSave.attachedTo.CutsceneTitle + "_" + attachedToSave.Title;
                    }
                    else
                    {
                        CutsceneTitle = "FollowUp_" + attachedToSave.Title;
                    }
                }
            }
            else
            {
                //make sure that will be only one connection to RPGTalkNode
                List <ConnectionPort> toDelete = new List <ConnectionPort>();
                foreach (ConnectionPort connected in outputPorts[0].connections)
                {
                    if (connection.body is RPGTalkNode)
                    {
                        if (connected != connection)
                        {
                            toDelete.Add(connected);
                        }
                    }
                    else if (connection.body is RPGTalkChoiceNode)
                    {
                        if (connected != connection && (connected.body is RPGTalkNode || connected.body is RPGTalkSaveNode))
                        {
                            toDelete.Add(connected);
                        }
                    }
                    else
                    {
                        if (connected != connection && (connected.body is RPGTalkNode || connected.body is RPGTalkChoiceNode))
                        {
                            toDelete.Add(connected);
                        }
                    }
                }

                foreach (ConnectionPort deleteMe in toDelete)
                {
                    outputPorts[0].RemoveConnection(deleteMe);
                }

                //Add choice
                if (connection.body is RPGTalkChoiceNode)
                {
                    choices.Add(connection.body as RPGTalkChoiceNode);
                }

                //Add save
                if (connection.body is RPGTalkSaveNode)
                {
                    saves.Add(connection.body as RPGTalkSaveNode);
                }
            }

            (NodeEditor.curNodeCanvas as RPGTalkNodeCanvas).GetNextLineInTxt();
        }