Exemple #1
0
    void StartDownLoad(AssetDownInfo info)
    {
        HttpDownLoadAsync loadAsync = CreateHttpDownLoad();

        loadAsync.Setup(info);
        loadAsync.StartDownLoad(_current_strategy.GetDownLoadParam(info));
    }
    protected HttpDownLoadAsync CreateHttpDownLoad()
    {
        HttpDownLoadAsync httpDownLoadAsync = new HttpDownLoadAsync(this);

        httpDownloadAsyncs.Add(httpDownLoadAsync);
        return(httpDownLoadAsync);
    }
    protected override void OnDownloadSuccessful(AssetDownInfo info, HttpDownLoadAsync loadAsync)
    {
        lock (LOCK_OBJ)
        {
            if (info.Buffer.Bytes.Length != info.BufferNumber)
            {
                byte[] bytes = new byte[info.BufferNumber];
                for (int i = 0; i < info.BufferNumber; i++)
                {
                    bytes[i] = info.Buffer.Bytes[i];
                }

                info.Buffer.Bytes = bytes;
            }

            OnDownLoadFileInfoSuccessful(info);

            versionIndex.Remove(info.Index);
            if (httpDownloadAsyncs.Contains(loadAsync))
            {
                httpDownloadAsyncs.Remove(loadAsync);
            }

            if (IsDownloadABatch())
            {
                OnAllDownLoadComplete();
                ClearHttpDownLoad();
                isDone = true;
            }
        }
    }
    public override void StartDownLoad()
    {
        VersionInfo info = FileManifestManager.Get <IServerVersionFileManifest>().GetLastVersin();

        if (info == null)
        {
            return;
        }
        if (info.AssetBundleManifestNames == null)
        {
            return;
        }

        for (int i = 0; i < info.AssetBundleManifestNames.Length; i++)
        {
            AssetBundleDownLoadParam param             = new AssetBundleDownLoadParam(info.AssetBundleManifestNames[i]);
            HttpDownLoadAsync        httpDownLoadAsync = CreateHttpDownLoad();

            AssetDownInfo downInfo = new AssetDownInfo();
            downInfo.AssetName       = info.AssetBundleManifestNames[i];
            downInfo.Buffer.ByteSize = int.Parse(info.AssetBundleManifestLengths[i]);
            downInfo.MD5             = info.AssetBundleManifestMD5s[i];
            downInfo.Index           = i;
            _version_index.Add(i);

            httpDownLoadAsync.Setup(downInfo);
            httpDownLoadAsync.StartDownLoad(param);
        }
    }
    public override void StartDownLoad()
    {
        HttpDownLoadAsync httpDownloadAsync = CreateHttpDownLoad();

        httpDownloadAsync.Setup(new AssetDownInfo());
        VersionListDownLoadParam versionListDownLoad = new VersionListDownLoadParam();

        httpDownloadAsync.StartDownLoad(versionListDownLoad);
    }
Exemple #6
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();
    }
 protected override void OnDownloadSuccessful(AssetDownInfo info, HttpDownLoadAsync loadAsync)
 {
     _version_index.Remove(info.Index);
     if (_version_index.Count <= 0)
     {
         OnAllDownLoadComplete();
         if (DownLoadCompleteEvent != null)
         {
             DownLoadCompleteEvent(this);
         }
     }
 }
    public void DownLoadError(AssetDownInfo info, HttpDownLoadAsync loadAsync)
    {
        lock (LOCK_OBJ)
        {
            DownLoadErrorEvent errorEvent = new DownLoadErrorEvent(info);
            errorEvent.Event = (dio) =>
            {
                OnDownLoadError(dio);

                if (httpDownloadAsyncs.Contains(loadAsync))
                {
                    httpDownloadAsyncs.Remove(loadAsync);
                }
            };
            downLoad_error_events.Enqueue(errorEvent);
        }
    }
    public void DownloadSuccessful(AssetDownInfo info, HttpDownLoadAsync loadAsync)
    {
        lock (LOCK_OBJ)
        {
            DownloadSuccessfulEvent successfulEvent = new DownloadSuccessfulEvent(info, loadAsync);
            successfulEvent.Event = (dif, la) =>
            {
                OnDownloadSuccessful(dif, la);

                if (httpDownloadAsyncs.Contains(loadAsync))
                {
                    httpDownloadAsyncs.Remove(loadAsync);
                }
            };

            download_successful_events.Enqueue(successfulEvent);
        }
    }
    public override void StartDownLoad()
    {
        _all_version = _server_version.GetABVersion();
        if (_all_version.Count <= 0)
        {
            base.OnAllDownLoadComplete();
            return;
        }

        for (int i = 0; i < _all_version.Count; i++)
        {
            HttpDownLoadAsync httpDownLoadAsync = CreateHttpDownLoad();

            _data_infos.Add(_all_version[i], new List <AssetDataInfo>());

            httpDownLoadAsync.Setup(NewAssetDownInfo(i));
            httpDownLoadAsync.StartDownLoad(new AssetBundleFileDownLoadParam(_all_version[i]));
        }
    }
    public override void StartDownLoad()
    {
        List <string> versionList = _server_version_list.GetAllVersion();

        if (versionList == null)
        {
            return;
        }

        _all_versions = GetNeedDownVersion(versionList);
        for (int i = 0; i < _all_versions.Count; i++)
        {
            HttpDownLoadAsync httpDownLoadAsync = CreateHttpDownLoad();

            _version_infos.Add(_all_versions[i], null);

            httpDownLoadAsync.Setup(NewAssetDownInfo(i));
            httpDownLoadAsync.StartDownLoad(new VersionDownLoadParam(_all_versions[i]));
        }
    }
 protected virtual void OnDownloadSuccessful(AssetDownInfo info, HttpDownLoadAsync loadAsync)
 {
 }
 public DownloadSuccessfulEvent(
     AssetDownInfo downInfo, HttpDownLoadAsync loadAsync)
 {
     _down_info  = downInfo;
     _load_async = loadAsync;
 }