少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-30 cfbb67a6a3ddf81abea300409a1ff37fd31df938
System/AssetVersion/DownLoadAndDiscompressTask.cs
@@ -1,36 +1,34 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Snxxz.UI;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using Snxxz.UI;
using System.Threading;
public class DownLoadAndDiscompressTask : Singleton<DownLoadAndDiscompressTask>
{
    public const int BYTE_PER_KILOBYTE = 1024;
    public const int BYTE_PER_MILLIONBYTE = 1048576;
    public float progress {
        get {
            return Mathf.Clamp01((float)RemoteFile.TotalDownloadedSize / totalSize);
        }
    }
    List<AssetVersion> tasks = new List<AssetVersion>();
    public float progress { get { return Mathf.Clamp01((float)RemoteFile.TotalDownloadedSize / totalSize); } }
    List<AssetVersion> tasks = new List<AssetVersion>();
    public bool isDone { get { return step == Step.Completed; } }
    public int totalSize { get; private set; }
    public int totalCount { get; private set; }
    public int okCount { get; private set; }
    public bool restartApp { get; private set; }
    public int okCount { get; private set; }
    public bool restartApp { get; private set; }
    public event Action<Step> downLoadStepChangeEvent;
    Action downLoadOkCallBack;
    Step m_Step = Step.None;
    public Step step {
    public Step step
    {
        get { return m_Step; }
        set {
        set
        {
            if (m_Step != value)
            {
                m_Step = value;
@@ -41,8 +39,8 @@
                }
            }
        }
    }
    }
    public void Prepare(List<AssetVersion> _downLoadTasks, Action _downLoadOkCallBack)
    {
        tasks = _downLoadTasks;
@@ -74,14 +72,14 @@
        {
            StartDownLoad();
        }
    }
    }
    public void StartDownLoad()
    {
        step = Step.DownLoad;
        SnxxzGame.Instance.StartCoroutine(Co_StartDownLoad());
    }
    }
    IEnumerator Co_StartDownLoad()
    {
        RemoteFile.maxDownLoadTask = 48;
@@ -121,8 +119,8 @@
        {
            SDKUtility.Instance.RestartApp();
        }
    }
    }
    private void OnFileDownLoadCompleted(bool _ok, AssetVersion _assetVersion)
    {
        var correctFile = false;
@@ -138,6 +136,7 @@
        }
        else
        {
            ExceptionCatcher.ReportException("游戏启动阶段文件下载失败", "文件名:" + _assetVersion.relativePath);
            var remoteURL = StringUtility.Contact(VersionUtility.Instance.versionInfo.GetResourcesURL(VersionConfig.Get().branch), "/", _assetVersion.relativePath);
            var localURL = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, _assetVersion.relativePath);
@@ -146,13 +145,13 @@
            remoteFile.Begin(OnFileDownLoadCompleted);
        }
    }
    public enum Step
    {
        None,
        DownLoadPrepared,
        DownLoad,
        Completed,
    }
}
    }
}