public bool AddTable(string key, LoadComplateCB lcCB) { if (tableList_ == null) { try { hashWaiting_.Add(key, lcCB); } catch { MagiDebug.LogError(string.Format("Table key already {0}", key)); } return(true); } else { string tableName; if (hashTableName_.TryGetValue(key, out tableName) == false) { if (key.Contains("weapontrail") || key.Contains("sound")) { MagiDebug.Log(string.Format("{0} table not found.", key)); return(false); } MagiDebug.LogError(string.Format("{0} table not found.", key)); return(false); } StartCoroutine(OpenTable(key, tableName, lcCB)); } return(true); }
void AddTableList() { if (tableList_ == null) { LoadComplateCB loadComplateCB = new LoadComplateCB(TableListLoadComplateCB); StartCoroutine(OpenTable("tablelist", "tablelist", loadComplateCB)); } }
IEnumerator OpenTable(string key, string tableName, LoadComplateCB lcCB) { string url = ""; MemoryStream stream = null; switch (OptionManager.Instance.pathType) { case OptionManager.EPathType.Develop: { url = OptionManager.ROOT_PATH + "/" + tableUrl_ + "/bytes/" + tableName + ".bytes"; TextAsset bytes = Resources.LoadAssetAtPath(url, typeof(TextAsset)) as TextAsset; if (bytes == null) { MagiDebug.Log(string.Format("{0}, bytes==null", url)); break; } stream = new MemoryStream(bytes.bytes); } break; case OptionManager.EPathType.Live: { AssetBundle assetBundle; if (PatchManager.Instance.FindAssetBundle("table", out assetBundle)) { TextAsset bytes = assetBundle.Load(key, typeof(TextAsset)) as TextAsset; if (bytes == null) { MagiDebug.LogError(key + " table not found."); yield break; } stream = new MemoryStream(bytes.bytes); } } break; } if (stream == null) { MagiDebug.Log(stream + "," + key + "," + tableName); yield break; } BinaryReader binReader = new BinaryReader(stream); Table table = new Table(key); int lineNum = binReader.ReadInt32(); int columnNum = binReader.ReadInt32(); if (ReadColumnName(columnNum, ref table, binReader) == false) { yield break; } if (ReadColumnType(columnNum, ref table, binReader) == false) { yield break; } for (int i = 0; i < lineNum; i++) { if (ReadData(columnNum, ref table, binReader) == false) { yield break; } } try { hashTable_.Add(key, table); } catch { MagiDebug.LogError(string.Format("Table key already {0}, {1}", key, tableName)); } if (lcCB != null) { lcCB(table); } }