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.ConditionalIf: { var node = new ConditionalExpressionNode(); 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); } case CommandType.SetVar: { var command = new SetVarNode(); 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); }