public Dialogue LoadDialogue(string filePath) { var doc = XDocument.Load(filePath); var dialogueNode = doc.Element("Dialogue"); string dialogueName = dialogueNode.Attribute("name").Value.ToString(); Dialogue dialogue = new Dialogue(Path.GetFileNameWithoutExtension(filePath)); string scriptPath = dialogueNode.Element("Script")?.Value; dialogue.ScriptPath = scriptPath; if (File.Exists(Constants.FILEPATH_DATA + "/" + scriptPath)) { dialogue.Script = Engine.Services.Get <ScriptManager>().CreateScript(Constants.FILEPATH_DATA + "/" + scriptPath); } var branchNodes = dialogueNode.Elements("Branch"); foreach (var branchNode in branchNodes) { string text = branchNode.Element("Text").Value; string branchName = branchNode.Attribute("name")?.Value; var branch = new DialogueBranch(dialogue, branchName, text); var responseNodes = branchNode.Elements("Response"); foreach (var responseNode in responseNodes) { var response = new DialogueResponse(); response.Text = responseNode.Value; response.Next = responseNode.Attribute("next")?.Value; response.Function = responseNode.Attribute("function")?.Value; response.Condition = responseNode.Attribute("condition")?.Value; branch.AddResponse(response); } dialogue.AddBranch(branch); } return(dialogue); }
public void RemoveResponse(DialogueResponse response) { _responses.Remove(response.UniqueID.ToString()); }
public void AddResponse(DialogueResponse response) { _responses.Add(response.UniqueID.ToString(), response); }