/// <summary> /// 具体的打开方案类 /// </summary> /// <param name="projectPath">方案文件路径</param> private void OpenProject(string projectPath) { if (searchNodeForm != null) { searchNodeForm.MustClose(); } searchNodeForm = new SearchNodeForm(); searchNodeForm.ShowSearchPanel = ShowSearchPanel; searchNodeForm.BasePanel = FlowLayoutPanel_Main; this.projectPath = projectPath; FlowLayoutPanel_Main.Controls.Clear(); dialogueConditionFileName = ""; //对话条件文件名 dialogueValueFileName = ""; //对话数据文件名 using (StreamReader fs = new StreamReader(this.projectPath, Encoding.UTF8)) { dialogueConditionFileName = fs.ReadLine(); dialogueValueFileName = fs.ReadLine(); } string folderPath = Path.GetDirectoryName(this.projectPath); string dialogueConditionStr = ""; string dialogueValueStr = ""; if (!string.IsNullOrEmpty(dialogueConditionFileName) && File.Exists(folderPath + "\\" + dialogueConditionFileName + ".txt")) { dialogueConditionStr = File.ReadAllText(folderPath + "\\" + dialogueConditionFileName + ".txt", Encoding.UTF8); } if (!string.IsNullOrEmpty(dialogueValueFileName) && File.Exists(folderPath + "\\" + dialogueValueFileName + ".txt")) { dialogueValueStr = File.ReadAllText(folderPath + "\\" + dialogueValueFileName + ".txt", Encoding.UTF8); } if (!string.IsNullOrEmpty(dialogueConditionFileName) && !string.IsNullOrEmpty(dialogueValueFileName)) { int maxID = dialogueAnalysisData.ReadData(dialogueConditionStr, dialogueValueStr); IDCreator.Instance.Init(maxID + 1); CreateControlByData(); 添加节点ToolStripMenuItem.Enabled = true; 除节点ToolStripMenuItem.Enabled = true; 保存方案ToolStripMenuItem.Enabled = true; 搜索节点ToolStripMenuItem.Enabled = true; 展开节点ToolStripMenuItem.Enabled = true; 收起节点ToolStripMenuItem.Enabled = true; } }
/// <summary> /// 从文件读取对话结构数据 /// </summary> /// <param name="must">是否必须读取</param> public void ReadDialogueStructData(bool must = false) { if (dialogueAnalysisData == null || must) { TextAsset dialogueTextAsset = Resources.Load <TextAsset>("Data/Dialogue/Dialogue"); if (dialogueTextAsset != null) { string[] pathNames = dialogueTextAsset.text.Split(new string[] { "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries); if (pathNames.Length == 2) { TextAsset dialogueConditionTextAsset = Resources.Load <TextAsset>("Data/Dialogue/" + pathNames[0]); TextAsset dialogueValueTextAsset = Resources.Load <TextAsset>("Data/Dialogue/" + pathNames[1]); if (dialogueConditionTextAsset != null && dialogueValueTextAsset != null) { dialogueAnalysisData.ReadData(dialogueConditionTextAsset.text, dialogueValueTextAsset.text); } } } } }