Beispiel #1
0
        private void OnLoadTableComplete(LoadResult result)
        {
            if (result.isSuccess)
            {
                bool   isSuccess    = true;
                string content      = "";
                string relativePath = result.assetNames[0];
                try
                {
                    TextAsset asset = result.assets[0] as TextAsset;
                    if (asset == null)
                    {
                        GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table asset is NULL,暂时跳过");
                        return;
                    }

                    content = asset.text;
                    if (string.IsNullOrEmpty(content))
                    {
                        GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table content is NULL or empty,暂时跳过");
                        return;
                    }

                    ResourcesProxy.DestroyAsset(relativePath);
                }
                catch (Exception e)
                {
                    isSuccess = false;
                    GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " Parse Failed : " + e.ToString());
                }
                finally
                {
                    if (isSuccess)
                    {
                        string     name      = relativePathToNameDict[relativePath];
                        ConfigData data      = m_TableDefine[name];
                        string     tableName = data.GetString("tableName");
                        string     tablePath = data.GetString("tablePath");
                        string     tablePK2  = data.GetString("extKey");

                        ConfigDataTableManager.Instance.LoadTable(tableName, content, tablePK2);
                    }
                    else
                    {
                        //TODO 留给之后对应加载的job使用
                    }
                }
            }
            else
            {
                //TODO 留给之后对应加载的job使用
                GameLogger.Error(LOG_CHANNEL.ASSET, result.assetNames[0] + " Load Failed!");
            }
        }
Beispiel #2
0
        private void OnResourcesSingleLoadComplete(Object defineObj)
        {
            UnityEngine.TextAsset textAsset = defineObj as UnityEngine.TextAsset;
            if (textAsset != null)
            {
                string     sContent = textAsset.text;
                ConfigData cd       = new ConfigData();

                int      idxkey1 = -1;
                string[] values  = sContent.Split("\r"[0]);
                string[] lables  = values[0].TrimStart('\n').Split(ClientConfigManager.CMD_STRING, StringSplitOptions.None);
                string[] types   = values[1].TrimStart('\n').Split(ClientConfigManager.CMD_STRING, StringSplitOptions.None);

                Dictionary <string, int> ColumnNameMap = new Dictionary <string, int>();
                for (int i = 0; i < lables.Length; ++i)
                {
                    if (string.IsNullOrEmpty(lables[i]))
                    {
                        continue;
                    }
                    ColumnNameMap.Add(lables[i], i);
                }

                List <ConfigData> dataList = new List <ConfigData>();
                for (int i = 2; (i < values.Length); i = (i + 1))
                {
                    string[] subValues = values[i].TrimStart('\n').Split(ClientConfigManager.CMD_STRING, StringSplitOptions.None);
                    if (subValues.Length != lables.Length)
                    {
                        continue;
                    }
                    ConfigData data = new ConfigData();
                    data.Init(lables.Length);

                    data.ColumnName2IDMap = ColumnNameMap;

                    int kV2 = -1;
                    if (idxkey1 >= 0)
                    {
                        kV2 = Convert.ToInt32(subValues[idxkey1]);
                    }
                    for (int a = 0; a < subValues.Length; a++)
                    {
                        data.AddValue(types[a], a, subValues[a]);
                    }
                    OnLoadConfig(data);
                }
            }
            ResourcesProxy.DestroyAsset(AVALUE_DEFINE_PATH);
        }
Beispiel #3
0
        private void OnLoadDefineTableComplete(LoadResult result)
        {
            if (result.isSuccess)
            {
                bool   isSuccess    = true;
                string relativePath = result.assetNames[0];
                string content      = "";
                try
                {
                    TextAsset asset = result.assets[0] as TextAsset;
                    if (asset == null)
                    {
                        GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table asset is NULL,暂时跳过");
                        return;
                    }

                    content = asset.text;
                    if (string.IsNullOrEmpty(content))
                    {
                        GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " ERROR! load table content is NULL or empty,暂时跳过");
                        return;
                    }

                    ResourcesProxy.DestroyAsset(relativePath);
                }
                catch (Exception e)
                {
                    isSuccess = false;
                    GameLogger.Error(LOG_CHANNEL.ASSET, relativePath + " Parse Failed : " + e.ToString());
                }
                finally
                {
                    if (isSuccess)
                    {
                        InitConfigData(content);
                        LoadAllTable();
                    }
                    else
                    {
                        //TODO 留给之后对应加载的job使用
                    }
                }
            }
            else
            {
                //TODO 留给之后对应加载的job使用
                GameLogger.Error(LOG_CHANNEL.ASSET, result.assetNames[0] + " Load Failed!");
            }
        }