// 如果s_ShapeData没有初始化,则去初始化他 static void ShapeDataCheckInit() { if (s_ShapeData == null) { s_ShapeData = new Dictionary <int, Shape>(); TableUtil objectTable = new TableUtil(); objectTable.OpenFromData("shape.txt"); for (int row = 0; row < objectTable.GetRecordsNum(); row++) { Shape shape = new Shape(); shape.shape = objectTable.GetValue(row, 1); for (int i = 0; i < 6; i++) { shape.action[i] = short.Parse(objectTable.GetValue(row, 2 + i)); } shape.row = short.Parse(objectTable.GetValue(row, 8)); shape.col = short.Parse(objectTable.GetValue(row, 9)); shape.shadow = float.Parse(objectTable.GetValue(row, 10)); ColorUtility.TryParseHtmlString(objectTable.GetValue(row, 11), out shape.color); shape.ai = short.Parse(objectTable.GetValue(row, 12)); shape.overridePre = objectTable.GetValue(row, 13); shape.abname = objectTable.GetValue(row, 15); s_ShapeData.Add(int.Parse(objectTable.GetValue(row, 0)), shape); } } }
static public T LoadAny <T>(String reskeyname) where T : UnityEngine.Object { #if UNITY_EDITOR if (m_resmap_object == null) { // object资源映射表 m_resmap_object = new Dictionary <string, string[]>(); TableUtil objectTable = new TableUtil(); objectTable.OpenFromData("resmap_object.txt"); for (int row = 0; row < objectTable.GetRecordsNum(); row++) { string[] s = new string[3]; s[0] = objectTable.GetValue(row, 1); s[1] = objectTable.GetValue(row, 2); s[2] = objectTable.GetValue(row, 3); m_resmap_object.Add(objectTable.GetValue(row, 0), s); } } #endif if (m_resmap_object == null || m_resmap_object.ContainsKey(reskeyname) == false) { Debug.Log(reskeyname + " is not found"); LogUtil.GetInstance().WriteGame(reskeyname + " is not found"); return(default(T)); } if (Const.ResourceMode == "assetbundle") { return((T)Load(m_resmap_object[reskeyname][1], m_resmap_object[reskeyname][2], typeof(T)) as T); } else { return(Resources.Load <T>(m_resmap_object[reskeyname][0])); } }
void InitResMap() { // sprite资源映射表 m_resmap_sprite = new Dictionary <string, string[]>(); TableUtil spriteTable = new TableUtil(); spriteTable.OpenFromData("resmap_sprite.txt"); for (int row = 0; row < spriteTable.GetRecordsNum(); row++) { string[] s = new string[3]; s[0] = spriteTable.GetValue(row, 1); s[1] = spriteTable.GetValue(row, 2); s[2] = spriteTable.GetValue(row, 3); m_resmap_sprite.Add(spriteTable.GetValue(row, 0), s); } // prefab资源映射表 m_resmap_prefab = new Dictionary <string, string[]>(); TableUtil prefabTable = new TableUtil(); prefabTable.OpenFromData("resmap_prefab.txt"); for (int row = 0; row < prefabTable.GetRecordsNum(); row++) { string[] s = new string[3]; s[0] = prefabTable.GetValue(row, 1); s[1] = prefabTable.GetValue(row, 2); s[2] = prefabTable.GetValue(row, 3); m_resmap_prefab.Add(prefabTable.GetValue(row, 0), s); } // object资源映射表 m_resmap_object = new Dictionary <string, string[]>(); TableUtil objectTable = new TableUtil(); objectTable.OpenFromData("resmap_object.txt"); for (int row = 0; row < objectTable.GetRecordsNum(); row++) { string[] s = new string[3]; s[0] = objectTable.GetValue(row, 1); s[1] = objectTable.GetValue(row, 2); s[2] = objectTable.GetValue(row, 3); m_resmap_object.Add(objectTable.GetValue(row, 0), s); } }
/// <summary> /// 初始化 /// </summary> private void Init() { for (int i = 1; i <= 4; i++) { _AudioSwitches.Add((AudioType)i, true); _AudioSources.Add((AudioType)i, null); } _AudioRoot = GameObject.Find("Audio").transform; _AudioSources[AudioType.UI] = _AudioRoot.Find("Audio_UI").GetComponent <AudioSourceAgent>(); _AudioSources[AudioType.BGM] = _AudioRoot.Find("Audio_BGM").GetComponent <AudioSourceAgent>(); _AudioSources[AudioType.EFFECT] = _AudioRoot.Find("Audio_Effect").GetComponent <AudioSourceAgent>(); _AudioSources[AudioType.EVENT] = _AudioRoot.Find("Audio_Event").GetComponent <AudioSourceAgent>(); /*GameObject go = new GameObject("Audio_Effect"); * go.transform.SetParent(_AudioRoot); * _AudioSources[AudioType.EFFECT] = go.AddComponent<AudioSourceAgent>(); * _AudioSources[AudioType.EFFECT].audioType = AudioType.EFFECT; * _AudioSources[AudioType.EFFECT].AudioSource.volume = 0.5f; * * go = new GameObject("Audio_Event"); * go.transform.SetParent(_AudioRoot); * _AudioSources[AudioType.EVENT] = go.AddComponent<AudioSourceAgent>(); * _AudioSources[AudioType.EVENT].audioType = AudioType.EVENT; * _AudioSources[AudioType.EVENT].AudioSource.volume = 0.5f;*/ // 读取配置 TableUtil config = new TableUtil(); config.OpenFromData("audio.txt"); for (int i = 0; i < config.GetRecordsNum(); i++) { int id = Convert.ToInt32(config.GetValue(i, 0)); AudioConfig ac = new AudioConfig(); ac.Type = (AudioType)Convert.ToInt32(config.GetValue(i, 1)); ac.ResName = config.GetValue(i, 2); ac.IsOverlay = config.GetValue(i, 4) == "1" ? true : false; _Configs.Add(id, ac); } }
static int GetValue(IntPtr L) { try { ToLua.CheckArgsCount(L, 3); TableUtil obj = (TableUtil)ToLua.CheckObject(L, 1, typeof(TableUtil)); int arg0 = (int)LuaDLL.luaL_checknumber(L, 2); int arg1 = (int)LuaDLL.luaL_checknumber(L, 3); string o = obj.GetValue(arg0, arg1); LuaDLL.lua_pushstring(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
public static void MaskWordInit() { if (s_MaskWord == null) { s_MaskWord = new List <string>(); TableUtil objectTable = new TableUtil(); objectTable.OpenFromData("MaskWord.txt"); for (int row = 0; row < objectTable.GetRecordsNum(); row++) { string word = objectTable.GetValue(row, 0); if (word != "") { s_MaskWord.Add(word); } } } }
// 根据选择语言进行初始化 public static int init() { destroy(); countryCodeTable = new Dictionary <string, string[]>(); countryIdTable = new Dictionary <int, string[]>(); languageCodeTable = new Dictionary <string, string[]>(); languageIdTable = new Dictionary <int, string[]>(); // 读取国家信息 TableUtil _countryTxt = new TableUtil(); if (_countryTxt.OpenFromData("localization_country.txt") == false) { return(-1); } for (int row = 0; row < _countryTxt.GetRecordsNum(); row++) { string countryCode = _countryTxt.GetValue(row, 0); // 国家英文代码(国际标准) string CountryID = _countryTxt.GetValue(row, 1); // 国家数字代码(国际标准) string CountryNameID = _countryTxt.GetValue(row, 2); // 国家名称ID string CountryFlag = _countryTxt.GetValue(row, 3); // 国旗资源名 string CountryMoney = _countryTxt.GetValue(row, 4); // 货币简称 // 英文编码作key if (countryCodeTable.ContainsKey(countryCode) == false) { string[] ls = new string[4]; ls[0] = CountryID; ls[1] = CountryNameID; ls[2] = CountryFlag; ls[3] = CountryMoney; countryCodeTable.Add(countryCode, ls); } // 数字编码作key if (countryIdTable.ContainsKey(Convert.ToInt32(CountryID)) == false) { string[] ls = new string[4]; ls[0] = countryCode; ls[1] = CountryNameID; ls[2] = CountryFlag; ls[3] = CountryMoney; countryIdTable.Add(Convert.ToInt32(CountryID), ls); } } // 读取语言信息 TableUtil _languageTxt = new TableUtil(); if (_languageTxt.OpenFromData("localization_language.txt") == false) { return(-2); } for (int row = 0; row < _languageTxt.GetRecordsNum(); row++) { string LanguageCode = _languageTxt.GetValue(row, 0); // 语言英文代码(国际标准) string LanguageCustomID = _languageTxt.GetValue(row, 1); // 语言自定义ID(无标准,暂时跟u3d里定义的语言ID走) string LanguageNameID = _languageTxt.GetValue(row, 2); // 语言名称ID string LanguageDirectory = _languageTxt.GetValue(row, 3); // 语言存在目录 string TranslationCode = _languageTxt.GetValue(row, 4); // 翻译Code // 英文编码作key if (languageCodeTable.ContainsKey(LanguageCode) == false) { string[] ls = new string[4]; ls[0] = LanguageCustomID; ls[1] = LanguageNameID; ls[2] = LanguageDirectory; ls[3] = TranslationCode; languageCodeTable.Add(LanguageCode, ls); } // 数字编码作key if (languageIdTable.ContainsKey(Convert.ToInt32(LanguageCustomID)) == false) { string[] ls = new string[4]; ls[0] = LanguageCode; ls[1] = LanguageNameID; ls[2] = LanguageDirectory; ls[3] = TranslationCode; languageIdTable.Add(Convert.ToInt32(LanguageCustomID), ls); } } // 用户本地配置文件里获取玩家已经选择的国家语言 IniUtil userIni = new IniUtil(); userIni.OpenFromTXT(PathUtil.ConfigPath() + "user.txt"); // 读取使用语言 currentLanguage = userIni.ReadValue("LANGUAGE", "").ToString(); if (currentLanguage == "") { // 没有存档的,使用设备当前的 currentLanguage = DeviceHelper.getLanguage(); userIni.WriteValue("LANGUAGE", currentLanguage); } // 读取使用国家 currentCountry = userIni.ReadValue("COUNTRY", "").ToString(); if (currentCountry == "") { // 没有存档的,使用设备当前的 currentCountry = DeviceHelper.getCountry(); userIni.WriteValue("COUNTRY", currentCountry); } // 先去语言信息里找一下,语言-地区的目录(如zh-cn),没有则直接使用语言(如zh,ru,en等),还是没有则使用英文的 string localizeDir = languageDirectory(currentLanguage + "-" + currentCountry); if (localizeDir == "") { localizeDir = languageDirectory(currentLanguage); if (localizeDir == "") { localizeDir = languageDirectory("en"); if (localizeDir == "") { return(-3); } } } localizeDir = localizeDir + "/"; // 读取基础文字表 TableUtil _localizetxt = new TableUtil(); localize = new Dictionary <int, string>(); if (_localizetxt.OpenFromData(localizeDir + "localize.txt") == false) { // 没有对应的语言文件夹,用英语的 localizeDir = languageDirectory("en") + "/"; if (_localizetxt.OpenFromData(localizeDir + "localize.txt") == false) { return(-4); } } for (int row = 0; row < _localizetxt.GetRecordsNum(); row++) { int key = Convert.ToInt32(_localizetxt.GetValue(row, 0)); string text = _localizetxt.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize.Add(key, text); } // 读取道具文字表 TableUtil _localizeItemTxt = new TableUtil(); localize_item = new Dictionary <int, string>(); if (_localizeItemTxt.OpenFromData(localizeDir + "localize_item.txt") == false) { // 没有对应的语言文件夹,用英语的 localizeDir = languageDirectory("en") + "/"; if (_localizeItemTxt.OpenFromData(localizeDir + "localize_item.txt") == false) { return(-5); } } for (int row = 0; row < _localizeItemTxt.GetRecordsNum(); row++) { int key = Convert.ToInt32(_localizeItemTxt.GetValue(row, 0)); string text = _localizeItemTxt.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize_item.Add(key, text); } // 读取任务文字表 TableUtil _localizeQuestTxt = new TableUtil(); localize_quest = new Dictionary <int, string>(); if (_localizeQuestTxt.OpenFromData(localizeDir + "localize_quest.txt") == false) { // 没有对应的语言文件夹,用英语的 localizeDir = languageDirectory("en") + "/"; if (_localizeQuestTxt.OpenFromData(localizeDir + "localize_quest.txt") == false) { return(-6); } } for (int row = 0; row < _localizeQuestTxt.GetRecordsNum(); row++) { int key = Convert.ToInt32(_localizeQuestTxt.GetValue(row, 0)); string text = _localizeQuestTxt.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize_quest.Add(key, text); } // 容错处理,所有找不到的文字使用英文 localizeDir = languageDirectory("en") + "/"; // 读取基础文字表 TableUtil localizetxt_en_us = new TableUtil(); localize_en_us = new Dictionary <int, string>(); localizetxt_en_us.OpenFromData(localizeDir + "localize.txt"); for (int row = 0; row < localizetxt_en_us.GetRecordsNum(); row++) { int key = Convert.ToInt32(localizetxt_en_us.GetValue(row, 0)); string text = localizetxt_en_us.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize_en_us.Add(key, text); } // 读取道具文字表 TableUtil localizeitemtxt_en_us = new TableUtil(); localize_item_en_us = new Dictionary <int, string>(); localizeitemtxt_en_us.OpenFromData(localizeDir + "localize_item.txt"); for (int row = 0; row < localizeitemtxt_en_us.GetRecordsNum(); row++) { int key = Convert.ToInt32(localizeitemtxt_en_us.GetValue(row, 0)); string text = localizeitemtxt_en_us.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize_item_en_us.Add(key, text); } // 读取任务文字表 TableUtil localizequesttxt_en_us = new TableUtil(); localize_quest_en_us = new Dictionary <int, string>(); localizequesttxt_en_us.OpenFromData(localizeDir + "localize_quest.txt"); for (int row = 0; row < localizequesttxt_en_us.GetRecordsNum(); row++) { int key = Convert.ToInt32(localizequesttxt_en_us.GetValue(row, 0)); string text = localizequesttxt_en_us.GetValue(row, 1); text = text.Replace("\\n", "\n"); localize_quest_en_us.Add(key, text); } bInited = true; return(0); }