Beispiel #1
0
        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);
        }
Beispiel #2
0
        /// <returns>
        /// Returns null if there is no active branching dialogue node in the conversation
        /// </returns>
        public BranchingDialogueNode GetActiveBranchingDialogueNode(string pConversation)
        {
            List <DialogueNode> nodesInConvo = GetNodesForConversation(pConversation);

            BranchingDialogueNode n = nodesInConvo.Find(o =>
                                                        (o.isOn) &&
                                                        (o.language == _language) &&
                                                        (o is BranchingDialogueNode)
                                                        ) as BranchingDialogueNode;

            return(n);
        }
Beispiel #3
0
        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 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);
        }