Example #1
0
    public override bool IsNodeAllowed(bool isNewNode = false)
    {
        DialogueDataNode nd = (DialogueDataNode)dataNode;

        if (nd.type == DialogueDataNode.Type.StartDialogue)
        {
            DialogueDataGraph graph = (DialogueDataGraph)currentEditor.GetData();

            if (graph.startDialogue != null && graph.startDialogue != nd)
            {
                return(false);
            }
        }

        return(true);
    }
Example #2
0
    protected override void OnNodeEditorDataChange()
    {
        DialogueDataGraph dialogueGraph = (DialogueDataGraph)dataGraph;

        if (dialogueGraph.nodes.Count > 0)
        {
            dialogueGraph.nodes.ForEach(node =>
            {
                DialogueDataNode dialogueDataNode = (DialogueDataNode)node;

                if (dialogueDataNode.type == DialogueDataNode.Type.StartDialogue && dialogueGraph.startDialogue == null)
                {
                    dialogueGraph.startDialogue = dialogueDataNode;
                }
            });
        }

        base.OnNodeEditorDataChange();
    }
Example #3
0
    public override bool IsConnectionAllowed(Node other, bool isNewConnection = false)
    {
        DialogueDataNode     dNode       = (DialogueDataNode)dataNode;
        DialogueDataNode     otherDNode  = (DialogueDataNode)other.dataNode;
        DialogueDataGraph    graph       = (DialogueDataGraph)currentEditor.GetData();
        List <DataGraphNode> connections = graph.GetNodeConnections(dNode);
        int connectionCount = connections.Count;

        if (otherDNode.type == DialogueDataNode.Type.StartDialogue)
        {
            return(false);
        }


        switch (dNode.type)
        {
        case DialogueDataNode.Type.EndDialogue:
            return(false);

        case DialogueDataNode.Type.StartDialogue:
            if (otherDNode.type == DialogueDataNode.Type.Answer ||
                otherDNode.type == DialogueDataNode.Type.OnTrue ||
                otherDNode.type == DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 0 : 1))
            {
                return(false);
            }
            break;

        case DialogueDataNode.Type.Text:
            if (otherDNode.type == DialogueDataNode.Type.Answer ||
                otherDNode.type == DialogueDataNode.Type.OnTrue ||
                otherDNode.type == DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 0 : 1))
            {
                return(false);
            }
            break;

        case DialogueDataNode.Type.Question:
            if (otherDNode.type != DialogueDataNode.Type.Answer || connectionCount > (isNewConnection ? 3 : 4))
            {
                return(false);
            }
            break;

        case DialogueDataNode.Type.Answer:
            if (otherDNode.type == DialogueDataNode.Type.Answer ||
                otherDNode.type == DialogueDataNode.Type.OnTrue ||
                otherDNode.type == DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 0 : 1))
            {
                return(false);
            }
            break;

        case DialogueDataNode.Type.Condition:
            if (otherDNode.type != DialogueDataNode.Type.OnTrue && otherDNode.type != DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 1 : 2))
            {
                return(false);
            }

            if (isNewConnection)
            {
                if (connections.Count > 0)
                {
                    DialogueDataNode left = (DialogueDataNode)connections[0];
                    if (left.type == otherDNode.type)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                if (connections.Count > 1)
                {
                    DialogueDataNode left  = (DialogueDataNode)connections[0];
                    DialogueDataNode right = (DialogueDataNode)connections[1];
                    if (left.type == right.type)
                    {
                        return(false);
                    }
                }
            }
            break;

        case DialogueDataNode.Type.OnTrue:
            if (otherDNode.type == DialogueDataNode.Type.Answer ||
                otherDNode.type == DialogueDataNode.Type.OnTrue ||
                otherDNode.type == DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 0 : 1))
            {
                return(false);
            }
            break;

        case DialogueDataNode.Type.OnFalse:
            if (otherDNode.type == DialogueDataNode.Type.Answer ||
                otherDNode.type == DialogueDataNode.Type.OnTrue ||
                otherDNode.type == DialogueDataNode.Type.OnFalse)
            {
                return(false);
            }
            if (connectionCount > (isNewConnection ? 0 : 1))
            {
                return(false);
            }
            break;
        }

        return(true);
    }