public static Dialog Fetch(string filename, string objectname) { var dialog = new Dialog(); dialog.Nodes = new Dictionary<int, DialogNode>(); string settingString = String.Join("\r\n", File.ReadAllLines("Content/Dialog/" + filename + ".js")); var nodeList = Newtonsoft.Json.Linq.JObject.Parse(settingString); foreach(var node in nodeList[objectname]["nodes"]) { var dialogNode = new DialogNode { Identifier = (int) (node["identifier"]), Text = node["text"].ToString(), Options = new Dictionary<string, int>() }; if (node.SelectToken("options") != null && node["options"].Any()) { foreach(var option in node["options"]) { dialogNode.Options.Add(option["text"].ToString(), (int)option["node"]); } } dialog.Nodes.Add(dialogNode.Identifier, dialogNode); } dialog.Continue(); return dialog; }
public static Dialog Fetch(string filename, string objectname) { var dialog = new Dialog(); dialog.Nodes = new Dictionary <int, DialogNode>(); string settingString = String.Join("\r\n", File.ReadAllLines("Content/Dialog/" + filename + ".js")); var nodeList = Newtonsoft.Json.Linq.JObject.Parse(settingString); foreach (var node in nodeList[objectname]["nodes"]) { var dialogNode = new DialogNode { Identifier = (int)(node["identifier"]), Text = node["text"].ToString(), Options = new Dictionary <string, int>() }; if (node.SelectToken("options") != null && node["options"].Any()) { foreach (var option in node["options"]) { dialogNode.Options.Add(option["text"].ToString(), (int)option["node"]); } } dialog.Nodes.Add(dialogNode.Identifier, dialogNode); } dialog.Continue(); return(dialog); }
public EventHandler <InteractEventArgs> SimpleChest(string name, List <Item> contents) { return((sender, args) => { if (_clearedChests.Contains(name)) { return; } var scene = ((OverworldScene)sender); var dialog = new Dialog(); dialog.Nodes.Add(1, new DialogNode { Identifier = 1, Text = "Found items:" }); foreach (var item in contents) { dialog.Nodes[1].Text += "\n" + item.Name; } dialog.OnExit = (o, eventArgs) => ((SRPGGame)scene.Game).Inventory.AddRange(contents); dialog.Continue(); scene.StartDialog(dialog); _clearedChests.Add(name); }); }
public EventHandler<InteractEventArgs> SimpleChest(string name, List<Item> contents) { return (sender, args) => { if (_clearedChests.Contains(name)) return; var scene = ((OverworldScene) sender); var dialog = new Dialog(); dialog.Nodes.Add(1, new DialogNode { Identifier = 1, Text = "Found items:" }); foreach(var item in contents) { dialog.Nodes[1].Text += "\n" + item.Name; } dialog.OnExit = (o, eventArgs) => ((SRPGGame) scene.Game).Inventory.AddRange(contents); dialog.Continue(); scene.StartDialog(dialog); _clearedChests.Add(name); }; }