Ejemplo n.º 1
0
        public void LoadTable(string name)
        {
            ConfigData data = m_TableDefine[name];
            string     path = data.GetString("tablePath");

            ResourcesProxy.LoadAsset(path, OnLoadTableComplete);
        }
Ejemplo n.º 2
0
        public void StartLoader()
        {
            List <client_config_define> defineList = ClientConfigManager.LAppInitLoader;

            if (defineList.Count == 0)
            {
                GameLogger.Warning(LOG_CHANNEL.ASSET, "NO Param table");
                return;
            }

            List <string> loadPaths = new List <string>();
            List <string> loadNames = new List <string>();

            foreach (client_config_define define in defineList)
            {
                string name    = define.tableName;
                string prePath = define.tablePath + name + strExtention;
                loadPaths.Add(prePath);
                loadNames.Add(name);
            }

            Object defineObj = ResourcesProxy.LoadAssetImmediately(AVALUE_DEFINE_PATH);

            if (defineObj != null)
            {
                OnResourcesSingleLoadComplete(defineObj);
            }
        }
Ejemplo n.º 3
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!");
            }
        }
Ejemplo n.º 4
0
 private void LoadAllTable()
 {
     if (m_TableDefine == null || relativePathToNameDict == null || relativePathToNameDict.Count == 0)
     {
         GameLogger.DebugLog(LOG_CHANNEL.ERROR, "数据管理表尚未加载完毕");
         return;
     }
     foreach (string path in relativePathToNameDict.Keys)
     {
         ResourcesProxy.LoadAsset(path, OnLoadTableComplete);
     }
 }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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!");
            }
        }
Ejemplo n.º 7
0
        public bool CreateEngineObj(bool bAsync)
        {
            if (m_EngineObj != null /* || GameLogicObjectPoolManager.Instance == null*/)
            {
                return(true);
            }
            int        nModelID  = GetModelID();
            ConfigData modelData = GameDataProxy.GetData("modelresdefine", nModelID);

            if (modelData == null)
            {
                return(false);
            }
            string strName = modelData.GetString("ModelName");

            m_strName = strName;

            ResourcesProxy.LoadAsset(strName, OnEngineObjectLoadEnd, null);
            return(true);
        }
Ejemplo n.º 8
0
        public void StartLoadDefineTableList()
        {
            string path = StaticParam.Config_Define_Path;

            ResourcesProxy.LoadAsset(path, OnLoadDefineTableComplete);
        }