Beispiel #1
0
    protected override void OnDownloadSuccessful(AssetDownInfo info, HttpDownLoadAsync loadAsync)
    {
        Debug.Log("Asset下载成功!");
        if (_downLoad_error.Contains(info))
        {
            _downLoad_error.Remove(info);
        }

        if (StageDataBase.CheckVersionIsDownLoadComplete(info.Version))
        {
            // 一个版本下载完毕
            VersionDownLoadComplete(info.Version);
        }

        _current_strategy.TryRemove(info);

        if (IsDone)
        {
            if (_stage_index < (_strategy_bases.Length - 1))
            {
                _stage_index++;
                Debug.Log("换阶段了 STAGE_INDEX=" + _stage_index);
            }
            else
            {
                if (_downLoad_error.Count <= 0)
                {
                    UpdateStageResult.DownLoad.ClearAll();
                }

                OnAllDownLoadComplete();
                if (DownLoadCompleteEvent != null)
                {
                    DownLoadCompleteEvent(this);
                }
                FileManifestManager.WriteABDataByCurrent();

                isDone = true;

                Debug.Log("全部下载完成!!!!!!!");
            }
        }
        else
        {
            AssetDataInfo dataInfo = info.ToAssetDataInfo();
            if (_current_strategy.AssetType == eUpdateAssetType.Zip)
            {
                FileManifestManager.UpdateLocalFenBaoData(dataInfo);
            }
            else
            {
                FileManifestManager.UpdateLocalABData(dataInfo);
            }
        }

        TryStartDownLoad();
    }
    // 开始解压缩
    public void StartDecompress()
    {
        UpdateStageResult.DownLoad.IsEnable    = false;
        UpdateStageResult.Compression.IsEnable = true;
        UpdateStageResult.Compression.ClearAll();

        var deItr = _decompress_queue.GetEnumerator();

        while (deItr.MoveNext())
        {
            UpdateStageResult.Compression.TotalSize += deItr.Current.TotalSize;
            UpdateStageResult.Compression.FileCount++;
        }
        deItr.Dispose();

        string localPath = AssetsCommon.LocalAssetPath;

        if (!Directory.Exists(localPath))
        {
            Directory.CreateDirectory(localPath);
        }

        AssetDownInfo[] tempDatas = new AssetDownInfo[_decompress_queue.Count];
        for (int i = 0; i < tempDatas.Length; i++)
        {
            int index = _decompress_queue[i].Index;
            tempDatas[index] = _decompress_queue[i];
        }

        for (int i = 0; i < tempDatas.Length; i++)
        {
            AssetDownInfo downInfo = tempDatas[i];

            string zipFileName = string.Format("{0}/{1}", localPath, downInfo.AssetName);
            List <AssetDataInfo> assetNames = ZipHelper.Decompress(
                zipFileName,
                localPath);

            AssetDataInfo dataInfo = downInfo.ToAssetDataInfo();
            dataInfo.IsCompressed = true;

            UpdateStageResult.Compression.CurrentCount++;
            FileManifestManager.UpdateLocalFenBaoData(dataInfo);

            for (int j = 0; j < assetNames.Count; j++)
            {
                FileManifestManager.UpdateLocalABData(assetNames[j]);
            }

            if (File.Exists(zipFileName))
            {
                File.Delete(zipFileName);
            }
        }

        UpdateStageResult.Compression.IsEnable = false;

        if (_owner.IsDownLoadAllVersion)
        {
            FileManifestManager.WriteFenBaoDataByServer();
        }
        else
        {
            FileManifestManager.WriteFenBaoDataByCurrent();
        }

        FileManifestManager.WriteABDataByCurrent();
    }