public void Execute(Node node, IListener listener, int textLevel = 1) { string next = null; switch (node.type) { case DialogueForest.Node.Type.Node: if (node.choices != null && node.choices.Count > 0) listener.Choice(node.name, node.choices.Select(x => this[x].name)); next = node.next; break; case DialogueForest.Node.Type.Text: listener.Text(node.name, textLevel); if (node.choices != null && node.choices.Count > 0) listener.Choice(node.name, node.choices.Select(x => this[x].name)); next = node.next; textLevel++; break; case DialogueForest.Node.Type.Set: listener.Set(node.variable, node.value); next = node.next; break; case DialogueForest.Node.Type.Branch: string key = listener.Get(node.variable); if (key == null || !node.branches.TryGetValue(key, out next)) node.branches.TryGetValue("_default", out next); break; default: break; } if (next != null) this.Execute(this[next], listener, textLevel); }