/// <summary> /// 加载技能文件(仅在验证客户端模式下使用,直接加载resource下的资源) /// </summary> /// <param name="_files">Files.</param> private void LoadSkillActionFile() { if (Platform.IsEditor) { // 载入全部资源 foreach (string filePath in Directory.GetFiles(ConfigMgr.ETC_PATH, "*")) { // meta文件不处理 if (filePath.Contains(".meta")) { continue; } // 转换路径 string tempPath = filePath.Replace("\\", "/"); string ex = Path.GetExtension(tempPath); if (string.Equals(ex, ".xml") && Path.GetFileName(tempPath).Contains("skill_action")) { etcSkillActionList.Add(ResourceMgr.Instance.Load(tempPath).ToString()); } } } else { // 取得skill_action综合文件,加载所有skill_action string resPath = string.Format("Assets/{0}", ConfigMgr.SKILL_ACTION_DICT); string resText = ResourceMgr.Instance.LoadText(resPath); if (string.IsNullOrEmpty(resText)) { NIDebug.Log("加载skill_action_dict文件失败。"); return; } string[] lines = GameUtility.Explode(resText, "\n"); foreach (string line in lines) { if (string.IsNullOrEmpty(line)) { continue; } resText = ResourceMgr.Instance.LoadText(line); if (string.IsNullOrEmpty(resText)) { NIDebug.Log("加载{0}文件失败。", line); continue; } etcSkillActionList.Add(ResourceMgr.Instance.LoadText(line)); } } }
static void Init(string aliasContent) { mAliasTable.Clear(); string[] lines = GameUtility.Explode(aliasContent, "\n"); string prefix = "#define"; int prefix_len = prefix.Length; foreach (string line in lines) { if (!line.StartsWith(prefix)) { continue; } string text = line.Substring(prefix_len).Trim(); int first_space_index = text.IndexOf(' '); if (first_space_index < 1) { continue; } string alias_name = text.Substring(0, first_space_index); string alias_text = text.Substring(first_space_index + 1).Trim(); if (alias_text.Length < 1) { continue; } if (alias_text.StartsWith("0x")) { mAliasTable.Add(alias_name, Convert.ToInt32(alias_text, 16)); continue; } if (alias_text.StartsWith("-0x")) { mAliasTable.Add(alias_name, -Convert.ToInt32(alias_text.Substring(1), 16)); continue; } int ch = alias_text[0]; if (((ch >= '0') && (ch <= '9')) || (ch == '-')) { mAliasTable.Add(alias_name, Convert.ToInt32(alias_text, 10)); continue; } // 整体作为字符 mAliasTable.Add(alias_name, alias_text.Substring(0, alias_text.Length)); } }