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())); }
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()); } }
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); }
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)); }
public abstract ConversationNode ToConversationNode(SclConversation conversation);