public static GetAbsolutePath ( string path ) : string | ||
path | string | |
Résultat | string |
public void PreloadSceneStories() { TableConfig.Level cfg = TableConfig.LevelProvider.Instance.GetLevel(m_Scene.SceneResId); if (null != cfg) { string[] filePath; int ct1 = cfg.SceneDslFile.Count; int ct2 = cfg.RoomDslFile.Count; filePath = new string[ct1 + ct2]; for (int i = 0; i < ct1; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.SceneDslFile[i]); } for (int i = 0; i < ct2; i++) { filePath[ct1 + i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.RoomDslFile[i]); } StoryConfigManager.Instance.LoadStories(m_Scene.SceneResId, string.Empty, filePath); Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(m_Scene.SceneResId); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { AddStoryInstance(pair.Key, pair.Value.Clone()); } } } }
private string GetAssetBundleFile(string res) { string path = HomePath.GetAbsolutePath(res); path = Path.ChangeExtension(path, ".ab"); return(path.ToLower()); }
private void ExecScript(string scriptFile) { try { if (string.IsNullOrEmpty(scriptFile)) { scriptFile = "Dsl/gm.dsl"; } string path = scriptFile; if (!File.Exists(path)) { path = HomePath.GetAbsolutePath(path); } if (!File.Exists(path)) { LogSystem.Warn("Can't find {0}.", scriptFile); return; } ClientGmStorySystem.Instance.Reset(); ClientGmStorySystem.Instance.LoadStory(path); ClientGmStorySystem.Instance.StartStory("main"); LogSystem.Warn("ExecScript {0} finish.", scriptFile); } catch (Exception ex) { LogSystem.Error("ExecScript exception:{0}\n{1}", ex.Message, ex.StackTrace); } }
public bool LoadFromBinary(string file) { long t1 = TimeUtility.GetElapsedTimeUs(); bool result = true; BinaryTable table = new BinaryTable(); table.Load(HomePath.GetAbsolutePath(file)); long t2 = TimeUtility.GetElapsedTimeUs(); long t3 = TimeUtility.GetElapsedTimeUs(); for (int index = 0; index < table.Records.Count; ++index) { try { TData data = new TData(); bool ret = data.ReadFromBinary(table, index); string info = string.Format("DataTableMgr.CollectDataFromBinary collectData Row:{0} failed!", index); LogSystem.Assert(ret, info); if (ret) { m_DataContainer.Add(data); } else { result = false; } } catch (System.Exception ex) { LogSystem.Error("CollectData failed. file:{0} rowIndex:{1}\nException:{2}\n{3}", file, index, ex.Message, ex.StackTrace); } } long t4 = TimeUtility.GetElapsedTimeUs(); LogSystem.Info("binary load {0} parse {1}, file {2}", t2 - t1, t4 - t3, file); return(result); }
private AiStoryInstanceInfo NewAiStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } AiStoryInstanceInfo instInfo = GetUnusedAiStoryInstanceInfoFromPool(storyId); if (null == instInfo) { int ct; string[] filePath; ct = overloadFiles.Length; filePath = new string[ct]; for (int i = 0; i < ct; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + overloadFiles[i]); } StoryConfigManager.Instance.LoadStories(m_Scene.SceneResId, _namespace, filePath); StoryInstance instance = StoryConfigManager.Instance.NewStoryInstance(storyId, m_Scene.SceneResId); if (instance == null) { if (logIfNotFound) { LogSystem.Error("Can't load story config, story:{0} scene:{1} !", storyId, m_Scene.SceneResId); } return(null); } for (int ix = 0; ix < filePath.Length; ++ix) { Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath[ix]); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { if (pair.Key != storyId) { AiStoryInstanceInfo info = new AiStoryInstanceInfo(); info.m_StoryInstance = pair.Value.Clone(); info.m_IsUsed = false; AddAiStoryInstanceInfoToPool(pair.Key, info); } } } } AiStoryInstanceInfo res = new AiStoryInstanceInfo(); res.m_StoryInstance = instance; res.m_IsUsed = true; AddAiStoryInstanceInfoToPool(storyId, res); return(res); } else { instInfo.m_IsUsed = true; return(instInfo); } }
private static void LoadCustomCommandsAndValues() { string cmdFile = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + "Story/Common/CustomCommands.dsl"); string valFile = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + "Story/Common/CustomValues.dsl"); Dsl.DslFile file1 = CustomCommandValueParser.LoadStory(cmdFile); Dsl.DslFile file2 = CustomCommandValueParser.LoadStory(valFile); CustomCommandValueParser.FirstParse(file1, file2); CustomCommandValueParser.FinalParse(file1, file2); }
public void PreloadNamespacedStory(string _namespace, string file) { string filePath = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + file); StoryConfigManager.Instance.LoadStories(0, _namespace, filePath); Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { AddStoryInstance(pair.Key, pair.Value.Clone()); } } }
public void PreloadAiStory(string _namespace, string file) { string filePath = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + file); StoryConfigManager.Instance.LoadStories(m_Scene.SceneResId, _namespace, filePath); Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { AiStoryInstanceInfo info = new AiStoryInstanceInfo(); info.m_StoryInstance = pair.Value.Clone(); info.m_IsUsed = false; AddAiStoryInstanceInfoToPool(pair.Key, info); } } }
private StoryInstance NewStoryInstance(string storyId, string _namespace, bool logIfNotFound, params string[] overloadFiles) { if (!string.IsNullOrEmpty(_namespace)) { storyId = string.Format("{0}:{1}", _namespace, storyId); } StoryInstance instance = GetStoryInstance(storyId); if (null == instance) { string[] filePath; if (overloadFiles.Length <= 0) { TableConfig.UserScript cfg = TableConfig.UserScriptProvider.Instance.GetUserScript(storyId); if (null != cfg) { filePath = new string[1]; filePath[0] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + cfg.DslFile); } else { if (logIfNotFound) { LogSystem.Error("Can't find story config, story:{0} !", storyId); } return(null); } } else { int ct = overloadFiles.Length; filePath = new string[ct]; for (int i = 0; i < ct; i++) { filePath[i] = HomePath.GetAbsolutePath(FilePathDefine_Server.C_DslPath + overloadFiles[i]); } } StoryConfigManager.Instance.LoadStories(0, _namespace, filePath); instance = StoryConfigManager.Instance.NewStoryInstance(storyId, 0); if (instance == null) { if (logIfNotFound) { LogSystem.Error("Can't load story config, story:{0} !", storyId); } return(null); } for (int ix = 0; ix < filePath.Length; ++ix) { Dictionary <string, StoryInstance> stories = StoryConfigManager.Instance.GetStories(filePath[ix]); if (null != stories) { foreach (KeyValuePair <string, StoryInstance> pair in stories) { if (pair.Key != storyId) { AddStoryInstance(pair.Key, pair.Value.Clone()); } } } } AddStoryInstance(storyId, instance); return(instance); } else { return(instance); } }