Inheritance: DialogueNode
Ejemplo n.º 1
0
        private TimedDialogueNode VisitTimedDialogueNode(DialogueNode pPrevious)
        {
                        #if DEBUG_WRITE
            Console.WriteLine("VisitTimedDialogueNode()");
                        #endif

            Token  speakerToken = match(Token.TokenType.NAME);
            string speaker      = speakerToken.getTokenString();

            Token  lineToken = match(Token.TokenType.QUOTED_STRING);
            string line      = lineToken.getTokenString();

            TimedDialogueNode n = _dialogueRunner.Create <TimedDialogueNode>(_conversationName, _language, (_nodeCounter++).ToString() + "_line_" + lineToken.LineNr);            // + " (" + line + ")");
            n.speaker = speaker;
            n.line    = line;
            n.CalculateAndSetTimeBasedOnLineLength(false);

            if (lookAheadType(1) == Token.TokenType.BRACKET_LEFT)
            {
                match(Token.TokenType.BRACKET_LEFT);
                string nodeCustomName = match(Token.TokenType.NAME).getTokenString();
                n.name = nodeCustomName;
                match(Token.TokenType.BRACKET_RIGHT);
            }

                        #if DEBUG_WRITE
            Console.WriteLine("Added TimedDialogueNode with name '" + n.name + "' and line '" + n.line + "'");
                        #endif

            AddLinkFromPreviousNode(pPrevious, n);

            return(n);
        }
Ejemplo n.º 2
0
        private TimedDialogueNode GetActiveTimedDialogueNode(string pConversation)
        {
            List <DialogueNode> nodesInConvo = GetNodesForConversation(pConversation);

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

            return(n);
        }
Ejemplo n.º 3
0
        private void PrintTimedDialogueNode(TimedDialogueNode pTimedDialogueNode)
        {
            Indentation();
            _output.Append(pTimedDialogueNode.speaker + ": \"" + pTimedDialogueNode.line + "\"");
            _output.Append("\n");

            if (pTimedDialogueNode.nextNode != "")
            {
                DialogueNode nextNode = _dialogueRunner.GetDialogueNode(_conversation, pTimedDialogueNode.nextNode);
                SwitchOnNode(nextNode);
            }
            else
            {
                throw new GrimmException("TimedDialogueNode with name '" + pTimedDialogueNode.name + "' doesn't have a next node");
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        private DialogueNode VisitOption(DialogueNode pScopeEndNode)
        {
                        #if DEBUG_WRITE
            Console.WriteLine("VisitOption()");
                        #endif

            Token t = match(Token.TokenType.QUOTED_STRING);
            match(Token.TokenType.COLON);

            TimedDialogueNode optionNode = _dialogueRunner.Create <TimedDialogueNode>(_conversationName, _language, (_nodeCounter++).ToString());
            optionNode.line    = t.getTokenString();
            optionNode.speaker = _playerCharacterName;
            optionNode.CalculateAndSetTimeBasedOnLineLength(true);

                        #if DEBUG_WRITE
            Console.WriteLine("Created an option node with the name '" + optionNode.name + "'" + " and line " + "'" + optionNode.line + "'");
                        #endif

            Nodes(optionNode, pScopeEndNode);

            return(optionNode);
        }
Ejemplo n.º 6
0
        private void PrintTimedDialogueNode(TimedDialogueNode pTimedDialogueNode)
        {
            Indentation();
            _output.Append(pTimedDialogueNode.speaker + ": \"" + pTimedDialogueNode.line + "\"");
            _output.Append("\n");

            if(pTimedDialogueNode.nextNode != "")
            {
                DialogueNode nextNode = _dialogueRunner.GetDialogueNode(_conversation, pTimedDialogueNode.nextNode);
                SwitchOnNode(nextNode);
            }
            else
            {
                throw new GrimmException("TimedDialogueNode with name '" + pTimedDialogueNode.name + "' doesn't have a next node");
            }
        }