Exemplo n.º 1
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();
        }
Exemplo n.º 2
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();
        }