Ejemplo n.º 1
0
        public override ConversationNode ToConversationNode(SclConversation conversation)
        {
            var replies = new List <PossibleReply>();

            foreach (var option in Options)
            {
                replies.Add(new PossibleReply(option.Caption, option.Contents.ToConversationNode(conversation)));
            }
            return(new Branch(InitialLine, replies.ToArray()));
        }
Ejemplo n.º 2
0
        public override ConversationNode ToConversationNode(SclConversation conversation)
        {
            switch (Command)
            {
            case "/goto":
                return(new DelayedMoveNode((friend) =>
                {
                    return conversation.GetNodeFromLabel(this.Arguments[0]);
                }));

            case "/end":
                return(new DelayedMoveNode((f) => null));

            case "/escape":
                return(new DelayedMoveNode((friend) =>
                {
                    friend.Memory.ConversationStack.Pop();
                    return conversation.GetNodeFromLabel(this.Arguments[0]);
                }));

            case "/label":
                DoNothingNode n = new DoNothingNode();
                conversation.AddLabeledNode(this.Arguments[0], n);
                return(n);

            case "/picture":
                return(new ImageFileLine("Data/" + this.Arguments[0]));

            case "/file":
                return(new DocumentFileLine("Data/" + this.Arguments[0]));

            case "/input":
                return(new Nodes.SetVariableNode(this.Arguments[0]));

            case "/set":
                return(new LambdaActionNode(async(friend) =>
                {
                    friend.Data.SetVariable(this.Arguments[0], this.Arguments[1]);
                    await friend.Overseer.Speaking.SendSystemMessage(friend, "Configuration property '" + Arguments[0] + "' set to '" + this.Arguments[1] + "'.");
                    friend.SavePersistentMemory();
                }));

            default:
                if (Command.StartsWith("/special:"))
                {
                    string specialName = Command.Substring("/special:".Length);
                    return(new SpecialActionNode(specialName, Arguments));
                }
                return(new DoNothingNode());
            }
        }
Ejemplo n.º 3
0
        public SclConversation ParseConversation(List <SclLexicalLine> lines, int atIndent, ref int currentLine)
        {
            SclConversation statementSequence = new SclConversation();

            while (currentLine < lines.Count)
            {
                if (lines[currentLine].IndentCount < atIndent)
                {
                    break;
                }
                ParseConversationLine(lines, atIndent, statementSequence, ref currentLine);
            }
            return(statementSequence);
        }
Ejemplo n.º 4
0
        public ConversationNode LoadFromFile(string filename)
        {
            // Load text into unparsed SclLine
            string[] lines = System.IO.File.ReadAllLines(filename);
            List <SclLexicalLine> sclLines = new List <SclLexicalLine>();

            foreach (var line in lines)
            {
                var sclLine = SCL.SclLexicalLine.Parse(line);
                if (sclLine != null)
                {
                    sclLines.Add(sclLine);
                }
            }


            int currentLine = 0;

            SclParser       p = new SclParser();
            SclConversation c = p.ParseConversation(sclLines, 0, ref currentLine);

            return(c.ToConversationNode(c));
        }
 public override ConversationNode ToConversationNode(SclConversation conversation)
 {
     return(new Line(this.Line));
 }
Ejemplo n.º 6
0
 public abstract ConversationNode ToConversationNode(SclConversation conversation);