/**
         * Returns if the given father has a direct line of dialogue nodes to get to
         * the child node.
         *
         * @param fatherView
         *            Father node
         * @param childView
         *            Child node
         * @return True if the father is related to child following only dialogue
         *         nodes, false otherwise
         */
        private bool isDirectFather(ConversationNodeView fatherView, ConversationNodeView childView)
        {
            bool isDirectFatherL = false;

            // Check if both nodes are dialogue nodes
            if (fatherView.getType() == ConversationNodeViewEnum.DIALOGUE && childView.getType() == ConversationNodeViewEnum.DIALOGUE)
            {
                // Check if the father is not a terminal node
                if (!fatherView.isTerminal())
                {
                    // If the only child of the father equals the child, there is a direct line
                    if (fatherView.getChildView(0) == childView)
                    {
                        isDirectFatherL = true;
                    }

                    // If not, keep searching with the only child of the father
                    else
                    {
                        isDirectFatherL = isDirectFather(fatherView.getChildView(0), childView);
                    }
                }
            }

            return(isDirectFatherL);
        }
        public override bool canAddChild(ConversationNodeView nodeView, int nodeType)
        {
            bool canAddChild = false;

            // A dialogue node only accepts nodes if it is terminal
            if (nodeView.getType() == ConversationNodeViewEnum.DIALOGUE && nodeView.isTerminal())
            {
                canAddChild = true;
            }

            // An option node only accepts dialogue nodes
            if (nodeView.getType() == ConversationNodeViewEnum.OPTION && nodeType == (int)ConversationNodeViewEnum.DIALOGUE)
            {
                canAddChild = true;
            }

            return(canAddChild);
        }
        public override int[] getAddableNodes(ConversationNodeView nodeView)
        {
            int[] addableNodes = null;

            // Dialogue nodes can add both dialogue and option nodes
            if (nodeView.getType() == ConversationNodeViewEnum.DIALOGUE)
            {
                addableNodes = new int[] { (int)ConversationNodeViewEnum.DIALOGUE, (int)ConversationNodeViewEnum.OPTION }
            }
            ;

            // Option nodes can only add dialogue nodes
            else if (nodeView.getType() == ConversationNodeViewEnum.OPTION)
            {
                addableNodes = new int[] { (int)ConversationNodeViewEnum.DIALOGUE }
            }
            ;

            return(addableNodes);
        }
        public override bool canDeleteLink(ConversationNodeView nodeView)
        {
            bool canLinkNode = false;

            // The node must not be the root
            if (nodeView != graphConversation.getRootNode())
            {
                // A dialogue node only can link it it is terminal
                if (nodeView.getType() == ConversationNodeViewEnum.DIALOGUE && nodeView.isTerminal())
                {
                    canLinkNode = true;
                }

                // An option node can always link to another node
                if (nodeView.getType() == ConversationNodeViewEnum.OPTION)
                {
                    canLinkNode = true;
                }
            }

            return(!canLinkNode && this.getAllNodesViews().Count > 1);
        }
        public override bool canLinkNodeTo(ConversationNodeView fatherView, ConversationNodeView childView)
        {
            bool canLinkNodeTo = false;

            // Check first if the nodes are different
            if (fatherView != childView)
            {
                // If the father is a dialogue node, it can link to another if it is terminal
                // Check also that the father is not a child of the child node, to prevent cycles
                if (fatherView.getType() == ConversationNodeViewEnum.DIALOGUE && fatherView.isTerminal() && !isDirectFather(childView, fatherView))
                {
                    canLinkNodeTo = true;
                }

                // If the father is an option node, it can only link to a dialogue node
                if (fatherView.getType() == ConversationNodeViewEnum.OPTION && childView.getType() == ConversationNodeViewEnum.DIALOGUE)
                {
                    canLinkNodeTo = true;
                }
            }

            return(canLinkNodeTo);
        }
Ejemplo n.º 6
0
    /**
     * Checks if there is a "go-back" tag in the given node. This is, if the
     * node is a DialogueNode, and is linked to the OptionNode from which came
     * from
     *
     * @param node
     *            Node (must be a DialogueNode) to check
     * @return True if the node has a "go-back" tag, false otherwise
     */
    public static bool thereIsGoBackTag(ConversationNodeView node)
    {
        bool goBackTag = false;

        // Perform the check only if the node is a DialogueNode and it has a child
        if (node.getType() == ConversationNodeViewEnum.DIALOGUE && node.getChildCount() > 0)
        {
            ConversationNodeView possibleFather = node.getChildView(0);

            // For each child of the possible father node, check if it match with the possible child
            for (int i = 0; i < possibleFather.getChildCount(); i++)
                if (possibleFather.getChildView(i) == node)
                    goBackTag = true;
        }

        return goBackTag;
    }
Ejemplo n.º 7
0
    /**
     * Checks if there is a "go-back" tag in the given node. This is, if the
     * node is a DialogueNode, and is linked to the OptionNode from which came
     * from
     *
     * @param node
     *            Node (must be a DialogueNode) to check
     * @return True if the node has a "go-back" tag, false otherwise
     */
    public static bool thereIsGoBackTag(ConversationNodeView node)
    {
        bool goBackTag = false;

        // Perform the check only if the node is a DialogueNode and it has a child
        if (node.getType() == ConversationNodeViewEnum.DIALOGUE && node.getChildCount() > 0)
        {
            ConversationNodeView possibleFather = node.getChildView(0);

            // For each child of the possible father node, check if it match with the possible child
            for (int i = 0; i < possibleFather.getChildCount(); i++)
            {
                if (possibleFather.getChildView(i) == node)
                {
                    goBackTag = true;
                }
            }
        }

        return(goBackTag);
    }