Inheritance: DialogueNode
コード例 #1
0
        private void PrintIfNode(IfDialogueNode pIfDialogueNode)
        {
            Indentation();

            _output.Append("IF");
            _indentationLevel++;
            SwitchOnNode(pIfDialogueNode.ifTrueNode);
            _indentationLevel--;
            foreach (ExpressionDialogueNode elifNode in pIfDialogueNode.elifNodes)
            {
                _output.Append("ELIF");
                _indentationLevel++;
                SwitchOnNode(elifNode);
                _indentationLevel--;
            }
            if (pIfDialogueNode.ifFalseNode != null)
            {
                _output.Append("ELSE\n");
                _indentationLevel++;
                SwitchOnNode(pIfDialogueNode.ifFalseNode);
                _indentationLevel--;
            }

            DialogueNode nextNode = _dialogueRunner.GetDialogueNode(_conversation, pIfDialogueNode.nextNode);

            SwitchOnNode(nextNode);
        }
コード例 #2
0
        private void PrintIfNode(IfDialogueNode pIfDialogueNode)
        {
            Indentation();

            _output.Append("IF");
            _indentationLevel++;
            SwitchOnNode(pIfDialogueNode.ifTrueNode);
            _indentationLevel--;
            foreach(ExpressionDialogueNode elifNode in pIfDialogueNode.elifNodes) {
                _output.Append("ELIF");
                _indentationLevel++;
                SwitchOnNode(elifNode);
                _indentationLevel--;
            }
            if(pIfDialogueNode.ifFalseNode != null) {
                _output.Append("ELSE\n");
                _indentationLevel++;
                SwitchOnNode(pIfDialogueNode.ifFalseNode);
                _indentationLevel--;
            }

            DialogueNode nextNode = _dialogueRunner.GetDialogueNode(_conversation, pIfDialogueNode.nextNode);
            SwitchOnNode(nextNode);
        }
コード例 #3
0
ファイル: DialogueScriptLoader.cs プロジェクト: defc0n1/Grimm
        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);
        }