private static void ParseNodeSay(Node root, TokenStream stream) { var node = new SayNode("", ""); root.AddChildNode(node); var parameter = stream.Pop(); while (parameter.TokenType == SemanticTokenType.NodeParameter) { var argumentValue = stream.Pop(); if (parameter.TokenValue == "actor:") { node.ActorId = argumentValue.TokenValue; } else if (parameter.TokenValue == "text:") { node.Text = argumentValue.TokenValue; } else { throw new Exception("Unknown parameter:" + parameter.TokenValue); } var nexttype = stream.GetCurrent().TokenType; if (nexttype != SemanticTokenType.NodeParameter) { break; } parameter = stream.Pop(); } }
private static Node ConstuctNode(BinaryReader br, Guid id, NodeType nodeType, CommandType commandType) { //Console.WriteLine(nodeType); switch (nodeType) { case NodeType.Script: { var scriptNode = new ScriptNode(); scriptNode.Id = id; scriptNode.readData(br); return(scriptNode); } case NodeType.Page: { var pageNode = new PageNode(); pageNode.Id = id; pageNode.readData(br); return(pageNode); } case NodeType.OnceOnly: { var onceOnly = new OnceOnlyNode(); onceOnly.Id = id; onceOnly.readData(br); return(onceOnly); } case NodeType.ConditionalTrue: { var node = new ConditionalTrueNode(); node.Id = id; node.readData(br); return(node); } case NodeType.ConditionalFalse: { var node = new ConditionalFalseNode(); node.Id = id; node.readData(br); return(node); } case NodeType.OptionsChoice: { var node = new ShowOptionsNode(); node.Id = id; node.readData(br); return(node); } case NodeType.Option: { var node = new OptionNode(); node.Id = id; node.readData(br); return(node); } case NodeType.ParallelNode: { var node = new ParallelNode(); node.Id = id; node.readData(br); return(node); } case NodeType.BlockNode: { var node = new BlockNode(); node.Id = id; node.readData(br); return(node); } case NodeType.Command: { switch (commandType) { case CommandType.Say: { var command = new SayNode(); command.Id = id; command.readData(br); return(command); } case CommandType.CallPage: { var command = new CallPageNode(); command.Id = id; command.readData(br); return(command); } case CommandType.Return: { var command = new ReturnNode(); command.Id = id; command.readData(br); return(command); } case CommandType.Wait: { var command = new WaitNode(); command.Id = id; command.readData(br); return(command); } case CommandType.Print: { var command = new PrintNode(); command.Id = id; command.readData(br); return(command); } default: throw new Exception("Unhandled Node Type:" + nodeType + ":" + commandType); } } // case NodeType.Say default: throw new Exception("Unhandled Node Type:" + nodeType); } return(null); }