Exemplo n.º 1
0
    public static void LoadResourceTable(string path)
    {
        resourcetable.Clear();
        ScpReader reader = new ScpReader(path, true);

        for (int i = 0; i < reader.GetRecordCount(); i++)
        {
            ResourceInfoEx currentinfo = new ResourceInfoEx();
            currentinfo.bundlename    = reader.GetString(i, 2, "");
            currentinfo.assetfilename = reader.GetString(i, 3, "");
            currentinfo.objectname    = reader.GetString(i, 1, "");
            currentinfo.classname     = reader.GetString(i, 0, "");
            currentinfo.typename      = reader.GetString(i, 4, "");
            currentinfo.path          = reader.GetString(i, 5, "");
            currentinfo.offset        = reader.GetLong(i, 6, -1);
            currentinfo.length        = reader.GetLong(i, 7, -1);
            if (resourcetable.ContainsKey(currentinfo.classname) == false)
            {
                resourcetable[currentinfo.classname] = new Dictionary <string, ResourceInfoEx>();
            }
            Dictionary <string, ResourceInfoEx> resourcelist = resourcetable[currentinfo.classname];
            resourcelist[currentinfo.objectname] = currentinfo;
        }

        reader.Dispose();

        Trace.Log("ResourceEx::LoadResourceTable:" + path + " finish");
    }
Exemplo n.º 2
0
        private void LoadTaskViewTimeConfig(string _strPath)
        {
            if (!File.Exists(_strPath))
            {
                return;
            }

            ScpReader reader = new ScpReader(_strPath, true, 2);

            for (int i = 0; i < reader.GetRecordCount(); i++)
            {
                long llContactID = reader.GetLong(i, (int)ETaskViewTimeConfigCol.ETVT_ID, 0);
                int  nViewTime   = reader.GetInt(i, (int)ETaskViewTimeConfigCol.ETVT_TIME, 0);

                m_mapTaskViewTime[llContactID] = nViewTime;
            }
        }
Exemplo n.º 3
0
    // 进入新的状态
    private void OnEnter(ResVerCheckState newState, ResVerCheckState oldState)
    {
        switch (newState)
        {
        case ResVerCheckState.Init:
        {
            try
            {
                // 用户目录不存在Package目录,创建Package目录
                if (!Directory.Exists(ResDef.OuterPackageDirectory))
                {
                    Directory.CreateDirectory(ResDef.OuterPackageDirectory);
                }
            }
            catch (Exception e)
            {
            }
        }
        break;

        case ResVerCheckState.Start:
        {
            m_bStartSucc = true;
        }
        break;

        case ResVerCheckState.DownPackCsv:
        {
//						// 判断User下载目录中有没有Local_Package.txt,没有就从Resources目录中拷贝
//						if (!File.Exists(ResDef.UserDownLoadDirectory + ResDef.LocalPackageFileName))
//                      {
//							TextAsset obj = (TextAsset)AssetSystem.Singleton.LoadFromResources(LoadType.CSVFile, "Scp/Package");
//                          ResTools.CreateFile(ResDef.LocalPackageFileName, ResDownFlag.PackCsvFile, obj.bytes);
//                      }

            // 请求下载New包配置文件
            uint uReqId = 0;
            ResDownManager.Instance.ReqDownLoadHandler(out uReqId, -1, ResDownFlag.PackCsvFile, ResDef.ResPackageCommonURL + ResDef.NetPackageFileName, ResDef.NewPackageFileName, this);
            m_ReqDownInfoDic.Add(uReqId, new ResDownInfo(ResDownState.NoDown, 0));
        }
        break;

        case ResVerCheckState.DownResCsv:
        {
            // 请求下载资源配置文件
            uint uReqId = 0;
            ResDownManager.Instance.ReqDownLoadHandler(out uReqId, -1, ResDownFlag.ResCsvFile, ResDef.ResPackageCommonURL + ResDef.ResourceFileName, ResDef.ResourceFileName, this);
            m_ReqDownInfoDic.Add(uReqId, new ResDownInfo(ResDownState.NoDown, 0));
        }
        break;

        case ResVerCheckState.ResVerCheck:
        {
            oldpackagelist = new Hashtable();
            newpackagelist = new Hashtable();
            newpackagekeys = new List <string>();
            checkcount     = 0;

            string NewPath = ResDef.OuterPackageDirectory + ResDef.NewPackageFileName;
            string OldPath = ResDef.OuterPackageDirectory + ResDef.CurrentPackageFileName;
            if (System.IO.File.Exists(OldPath))
            {
                string    pText     = System.IO.File.ReadAllText(OldPath);
                ScpReader scpreader = new ScpReader(pText, "oldpackagecfg");
                int       n         = scpreader.GetRecordCount();
                for (int i = 0; i < n; i++)
                {
                    string packname   = scpreader.GetString(i, 1, "");
                    int    ver        = scpreader.GetInt(i, 2, 0);
                    long   filelength = scpreader.GetLong(i, 3, 0);
                    long   datatime   = scpreader.GetLong(i, 4, 0);
                    if (packname.Length > 0 && ver > 0 && datatime > 0)
                    {
                        PackageInfo packageinfo = new PackageInfo();
                        packageinfo.name         = packname;
                        packageinfo.ver          = ver;
                        packageinfo.filelength   = filelength;
                        packageinfo.datatime     = datatime;
                        oldpackagelist[packname] = packageinfo;
                    }
                }
                Trace.Log("oldpackagelist count=" + oldpackagelist.Count.ToString());
                scpreader.Dispose();
            }
            if (System.IO.File.Exists(NewPath))
            {
                string    pText     = System.IO.File.ReadAllText(NewPath);
                ScpReader scpreader = new ScpReader(pText, "newpackagecfg");
                int       n         = scpreader.GetRecordCount();
                for (int i = 0; i < n; i++)
                {
                    string packname   = scpreader.GetString(i, 1, "");
                    int    ver        = scpreader.GetInt(i, 2, 0);
                    long   filelength = scpreader.GetLong(i, 3, 0);
                    long   datatime   = scpreader.GetLong(i, 4, 0);
                    if (packname.Length > 0 && ver > 0 && datatime > 0)
                    {
                        PackageInfo packageinfo = new PackageInfo();
                        packageinfo.name         = packname;
                        packageinfo.ver          = ver;
                        packageinfo.filelength   = filelength;
                        packageinfo.datatime     = datatime;
                        newpackagelist[packname] = packageinfo;
                        newpackagekeys.Add(packname);
                    }
                }
                Trace.Log("newpackagelist count=" + newpackagelist.Count.ToString());
                Trace.Log("newpackagekeys count=" + newpackagekeys.Count.ToString());
                scpreader.Dispose();
            }

//						foreach(DictionaryEntry newkeypair in newpackagelist)
//						{
//							string newpackagename=(string)newkeypair.Key;
//							PackageInfo newpackageinfo=(PackageInfo)newkeypair.Value;
//							if (oldpackagelist.Contains(newpackagename))
//							{
//								PackageInfo oldpackageinfo=(PackageInfo)oldpackagelist[newpackagename];
//								//有更新变化
//								if (newpackageinfo.ver>oldpackageinfo.ver ||
//									newpackageinfo.filelength!=oldpackageinfo.filelength||
//									newpackageinfo.datatime!=oldpackageinfo.datatime)
//								{
//									m_NeedDownPackList.Add(newpackagename);
//								}
//								else//无更新变化
//								{
//									string destpath= ResDef.UserPackageDirectory+newpackagename+ext;
//									//文件不存在,重新下
//									if (System.IO.File.Exists(destpath)==false)
//									{
//										m_NeedDownPackList.Add(newpackagename);
//										continue;
//									}
//
//									//本地文件大小跟配置的不一样,重新下
//									FileInfo fi = new FileInfo(destpath);
//									if (fi.Length!=newpackageinfo.filelength)
//									{
//										m_NeedDownPackList.Add(newpackagename);
//										continue;
//									}
//								}
//							}
//							// 新增包
//					        else
//					        {
//					            m_NeedDownPackList.Add(newpackagename);
//					        }
//						}

            // 资源版本检查完成
            //m_bResVerCheckIsOver = true;
        }
        break;

        case ResVerCheckState.DownResPack:
        {
            if (m_NeedDownPackList.Count > 0)
            {
                for (int i = 0; i < m_NeedDownPackList.Count; ++i)
                {
                    // 获取对应的New包配置数据
                    //PackageData data = m_newPackageCsv.GetCsvValue(m_NeedDownPackList[i]);
                    string packname = m_NeedDownPackList[i] + ext;

                    // 请求下载资源包
                    uint uReqId = 0;
                    ResDownManager.Instance.ReqDownLoadHandler(out uReqId, -1, ResDownFlag.ResPackage, ResDef.ResPackageCommonURL + packname, packname, this);
                    m_ReqDownInfoDic.Add(uReqId, new ResDownInfo(ResDownState.NoDown, 0));
                }

                // todo开始显示进度条
            }
        }
        break;

        case ResVerCheckState.Finished:
        {
            // 取消订阅Update事件
            //SubscribeUpdateEvent(false);

            string NewPath = ResDef.OuterPackageDirectory + ResDef.NewPackageFileName;
            string OldPath = ResDef.OuterPackageDirectory + ResDef.CurrentPackageFileName;

            //copy new_package.csv as local_package.csv
            if (File.Exists(NewPath))
            {
                File.Copy(NewPath, OldPath, true);
            }



            // 资源版本管理流程结束
            bResVerMgrIsOver = true;
        }
        break;

        default:
            break;
        }
    }