/** * 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 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); }