コード例 #1
0
        IEnumerable <object> DownloadUpdate(string svrVer)
        {
            loadRootPath = _updateUrl + svrVer + "/";

            FirstUtil.OutVersion = svrVer;
            newVersion           = svrVer;
            FirstUtil.newVersion = svrVer;

            yield return(BeginDownLoad(loadRootPath + "filelist.txt?id=" + (DateTime.Now.ToFileTime() / 10), 5));

            string txt = EndDownLoadTxt();

            if (string.IsNullOrEmpty(txt))
            {
                _infoTips = FirstLang.FIRST_MSG_8;
                yield return(null);

                yield break;
            }

            oldFileDic = FirstResource.SdFileDic;
            FirstResource.InitSdFileList(txt);

            yield return(BeginDownLoad(loadRootPath + FirstUtil.platform + "/filesize.assetbundle", 2));

            txt = EndDownLoadTxt("filesize");
            if (string.IsNullOrEmpty(txt))
            {
                _infoTips = FirstLang.FIRST_MSG_8;
                yield return(null);

                yield break;
            }

            parseSizeFile(txt);
            txt = null;
            foreach (var pair in FirstResource.SdFileDic)
            {
                string oldVersion;
                if (!oldFileDic.TryGetValue(pair.Key, out oldVersion) || oldVersion != pair.Value)
                {
                    downList.Add(pair.Key);
                    if (_fielSizeDic.ContainsKey(pair.Key))
                    {
                        allSize += _fielSizeDic[pair.Key];
                    }
                }
            }
            allDown = downList.Count;
            WriteLog("need download: " + allDown);

            if (allDown > 0)
            {
                startValue     = ProcessPercent;
                leftValue      = 100 - startValue;
                ProcessPercent = startValue + leftValue * currSize / allSize;
            }

            if (allDown == 0)
            {
                LoadComplete();
            }
            else
            {
                if (allSize > 1024 && Application.internetReachability != NetworkReachability.ReachableViaLocalAreaNetwork)
                {
                    double size = Math.Round(1.0f * allSize / 1024, 2);
                    if (load != null)
                    {
                        load.ShowAlert(size, OnConfirm, OnCancel);
                    }
                }
                else
                {
                    LoadMultiAsset(downList);
                }
            }
        }
コード例 #2
0
        IEnumerator InitInfos()
        {
            FirstRecordMsg.Init();

            gameObject.AddComponent <FirstPlatform>();

            string path = FirstUtil.GetStreamingAssetsPathNoTarget() + "version.txt";
            WWW    www  = new WWW(path);

            yield return(www);

            localVersion = getWWWTxt(www, false);
            www          = null;

            path = FirstUtil.GetStreamingAssetsPathNoTarget() + "gameDefine.txt";
            www  = new WWW(path);
            yield return(www);

            localGameDefine = getWWWTxt(www, false);
            www             = null;

            path = FirstUtil.GetStreamingAssetsPathNoTarget() + "filelist.txt";
            www  = new WWW(path);
            yield return(www);

            loccalFileList = getWWWTxt(www, false);
            www            = null;

            InitLocalInfo();

            InitOutDir();

            path = GetPathNoTarget("version.txt");
            www  = new WWW(path);
            yield return(www);

            outLocalVersion = getWWWTxt(www);
            www             = null;

            path = GetPathNoTarget("gameDefine.txt");
            www  = new WWW(path);
            yield return(www);

            outLocalGameDefine = getWWWTxt(www);
            www = null;

            path = GetPathNoTarget("filelist.txt");
            www  = new WWW(path);
            yield return(www);

            outloccalFileList = getWWWTxt(www, false);
            www = null;

            path = GetPathNoTarget("FirstLang.txt");
            www  = new WWW(path);
            yield return(www);

            InitLang(getWWWTxt(www, false));
            www = null;

            WriteLog("InitFilstInfo");

            InitData();

            StartCoroutine(CheckUpdate());

            FirstResource.InitAppFileList(loccalFileList);
#if UNITY_EDITOR
            FirstResource.InitSdFileList("");
#else
            FirstResource.InitSdFileList(outloccalFileList);
#endif

            localVersion       = null;
            outLocalVersion    = null;
            localGameDefine    = null;
            outLocalGameDefine = null;
            loccalFileList     = null;
            outloccalFileList  = null;

            StartCoroutine(WorkerUI());
        }