private void PrintUnifiedEndNodeForScope(UnifiedEndNodeForScope pUnifiedEndNodeForScope) { D.isNull(pUnifiedEndNodeForScope); //Indentation(); //_output.Append("end\n"); }
private DialogueNode VisitBranchingDialogueNode(DialogueNode pPrevious) { #if DEBUG_WRITE Console.WriteLine("NodesWithPlayerChoiceLinks()"); #endif if (lookAheadType(1) == Token.TokenType.CHOICE) { match(Token.TokenType.CHOICE); } bool eternal = lookAheadType(1) == Token.TokenType.ETERNAL; if (eternal) { match(Token.TokenType.ETERNAL); } match(Token.TokenType.BLOCK_BEGIN); BranchingDialogueNode bn = _dialogueRunner.Create <BranchingDialogueNode>(_conversationName, _language, (_nodeCounter++).ToString() + " (branching node)"); pPrevious.nextNode = bn.name; UnifiedEndNodeForScope unifiedEndNodeForScope = _dialogueRunner.Create <UnifiedEndNodeForScope>(_conversationName, _language, (_nodeCounter++) + " (unified end of options)"); bn.unifiedEndNodeForScope = unifiedEndNodeForScope.name; #if DEBUG_WRITE Console.WriteLine("Created a branching node with name '" + bn.name + "'"); #endif List <string> nameOfPossibleOptions = new List <string>(); while (lookAheadType(1) != Token.TokenType.EOF && lookAheadType(1) != Token.TokenType.BLOCK_END) { DialogueNode n = FigureOutOptionStatement(unifiedEndNodeForScope); if (n != null) { nameOfPossibleOptions.Add(n.name); } } bn.nextNodes = nameOfPossibleOptions.ToArray(); bn.eternal = eternal; if (bn.nextNodes.Length < 2) { Console.WriteLine("\nWarning! Branching node " + bn.name + " with only " + bn.nextNodes.Length + " nodes in " + _conversationName); } match(Token.TokenType.BLOCK_END); return(unifiedEndNodeForScope); }
private void PrintBranchingDialogueNode(BranchingDialogueNode pBranchingDialogueNode) { D.isNull(pBranchingDialogueNode); Indentation(); _output.Append("{\n"); _indentationLevel++; int optionNr = 1; foreach (string s in pBranchingDialogueNode.nextNodes) { TimedDialogueNode optionNode = _dialogueRunner.GetDialogueNode(_conversation, s) as TimedDialogueNode; D.isNull(optionNode); Indentation(); _output.Append(optionNr++ + ". \"" + optionNode.line + "\":\n"); D.assert(optionNode.nextNode != ""); DialogueNode nodePointedToByOption = _dialogueRunner.GetDialogueNode(_conversation, optionNode.nextNode); D.isNull(nodePointedToByOption); _indentationLevel++; SwitchOnNode(nodePointedToByOption); _indentationLevel--; } _indentationLevel--; Indentation(); _output.Append("}\n"); D.assert(pBranchingDialogueNode.name != ""); UnifiedEndNodeForScope unifiedEndNodeForScope = _dialogueRunner.GetDialogueNode(_conversation, pBranchingDialogueNode.unifiedEndNodeForScope) as UnifiedEndNodeForScope; D.isNull(unifiedEndNodeForScope); D.assert(unifiedEndNodeForScope.name != ""); //Console.WriteLine("Unified end node " + unifiedEndNodeForScope.name + " has next node " + unifiedEndNodeForScope.nextNode); DialogueNode nextNode = _dialogueRunner.GetDialogueNode(_conversation, unifiedEndNodeForScope.nextNode); //Console.WriteLine("Next node has type " + nextNode.GetType()); D.isNull(nextNode); SwitchOnNode(nextNode); }
private DialogueNode VisitIfDialogueNode(DialogueNode pPrevious) { #if DEBUG_WRITE Console.WriteLine("IfDialogueNode()"); #endif match(Token.TokenType.IF); string expressionName = ""; string[] args = VisitFunctionCall(out expressionName); AllowLineBreak(); match(Token.TokenType.BLOCK_BEGIN); UnifiedEndNodeForScope unifiedEndNode = _dialogueRunner.Create <UnifiedEndNodeForScope>(_conversationName, _language, (_nodeCounter++) + " (unified end of if)"); ExpressionDialogueNode ifTrue = _dialogueRunner.Create <ExpressionDialogueNode>(_conversationName, _language, (_nodeCounter++) + " (if true)"); Nodes(ifTrue, unifiedEndNode); ifTrue.expression = expressionName; ifTrue.args = args; #if DEBUG_WRITE Console.WriteLine("Added IfTrue node with expression '" + ifTrue.expression + "'"); #endif match(Token.TokenType.BLOCK_END); AllowLineBreak(); ImmediateNode ifFalse = null; List <ExpressionDialogueNode> elifNodes = new List <ExpressionDialogueNode>(); while (lookAheadType(1) == Token.TokenType.ELIF) { match(Token.TokenType.ELIF); string elifExpressionName = ""; string[] elifArgs = VisitFunctionCall(out elifExpressionName); AllowLineBreak(); match(Token.TokenType.BLOCK_BEGIN); ExpressionDialogueNode elifNode = _dialogueRunner.Create <ExpressionDialogueNode>(_conversationName, _language, (_nodeCounter++) + " (elif)"); Nodes(elifNode, unifiedEndNode); elifNode.expression = elifExpressionName; elifNode.args = elifArgs; elifNodes.Add(elifNode); #if DEBUG_WRITE Console.WriteLine("Added Elif node with expression '" + elifNode.expression + "'"); #endif match(Token.TokenType.BLOCK_END); AllowLineBreak(); } if (lookAheadType(1) == Token.TokenType.ELSE) { match(Token.TokenType.ELSE); AllowLineBreak(); match(Token.TokenType.BLOCK_BEGIN); ifFalse = _dialogueRunner.Create <ImmediateNode>(_conversationName, _language, (_nodeCounter++) + " (if false)"); Nodes(ifFalse, unifiedEndNode); match(Token.TokenType.BLOCK_END); } IfDialogueNode ifNode = _dialogueRunner.Create <IfDialogueNode>(_conversationName, _language, (_nodeCounter++) + " (if)"); #if DEBUG_WRITE Console.WriteLine("Added IfDialogueNode() with name '" + ifNode.name + "'"); //foreach(DialogueNode elif in elifNodes) { // Console.WriteLine("Added ElifDialogueNode() with name '" + elif.name + "'"); //} #endif AddLinkFromPreviousNode(pPrevious, ifNode); ifNode.nextNode = unifiedEndNode.name; ifNode.ifTrueNode = ifTrue; ifNode.elifNodes = elifNodes.ToArray(); if (ifFalse != null) { ifNode.ifFalseNode = ifFalse; } else { ifNode.ifFalseNode = null; } if (!_dialogueRunner.HasExpression(expressionName)) { //throw new GrimmException("There is no '" + expressionName + "' expression registered in the dialogue runner"); } return(unifiedEndNode); }