Exemplo n.º 1
0
        private IEnumerator Checking()
        {
            if (!Directory.Exists(_savePath))
            {
                Directory.CreateDirectory(_savePath);
            }
            enableVFS = true;
            yield return(RequestCopy());

            yield return(RequestVersions());

            if (_versions.Count > 0)
            {
                OnMessage("正在检查版本信息...");
                PrepareDownloads();
                var totalSize = _downloader.size;
                if (totalSize > 0)
                {
                    var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize));
                    var mb   = MessageBox.Show("提示", tips, "下载", "跳过");
                    yield return(mb);

                    if (mb.isOk)
                    {
                        _downloader.StartDownload();
                        yield break;
                    }
                }
            }

            OnComplete();
        }
Exemplo n.º 2
0
        private IEnumerator Checking()
        {
            if (!Directory.Exists(_savePath))
            {
                Directory.CreateDirectory(_savePath);
            }

            if (_step == Step.Wait)
            {
                yield return(RequestVFS());

                _step = Step.Copy;
            }

            if (_step == Step.Copy)
            {
                yield return(RequestCopy());
            }

            if (_step == Step.Coping)
            {
                var path     = _savePath + Versions.Filename + ".tmp";
                var versions = Versions.LoadVersions(path);
                var basePath = GetStreamingAssetsPath() + "/";
                yield return(UpdateCopy(versions, basePath));

                _step = Step.Versions;
            }

            if (_step == Step.Versions)
            {
                yield return(RequestVersions());
            }

            if (_step == Step.Prepared)
            {
                OnMessage("正在检查版本信息...");
                var totalSize = _downloader.size;
                if (totalSize > 0)
                {
                    var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize));
                    var mb   = MessageBox.Show("提示", tips, "下载", "退出");
                    yield return(mb);

                    if (mb.isOk)
                    {
                        _downloader.StartDownload();
                        _step = Step.Download;
                    }
                    else
                    {
                        Quit();
                    }
                }
                else
                {
                    OnComplete();
                }
            }
        }
Exemplo n.º 3
0
        private IEnumerator Checking()
        {
            if (!Directory.Exists(_savePath))
            {
                Directory.CreateDirectory(_savePath);
            }
            if (_step == STEP_IDLE)
            {
#if UNITY_IOS
                enableVFS = false;
#else
                enableVFS = true;
#endif
                _step = STEP_COPY;
            }

            if (_step == STEP_COPY)
            {
                yield return(RequestCopy());

                _step = STEP_VERSIONS;
            }

            if (_step == STEP_VERSIONS)
            {
                yield return(RequestVersions());
            }
            if (_versions.Count > 0)
            {
                OnMessage("正在检查版本信息...");
                PrepareDownloads();
                var totalSize = _downloader.size;
                if (totalSize > 0)
                {
                    var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize));
                    var mb   = MessageBox.Show("提示", tips, "[下载]", "[退出游戏]");
                    yield return(mb);

                    if (mb.isOk)
                    {
                        _step = STEP_DOWNLOAD;
                        _downloader.StartDownload();
                        yield break;
                    }
                    else
                    {
                        Quit();
                    }
                }
            }

            OnComplete();
        }
Exemplo n.º 4
0
        private IEnumerator Checking()
        {
            if (!Directory.Exists(_savePath))
            {
                Directory.CreateDirectory(_savePath);
            }

            this.Step = Step.Copy;

            if (this.Step == Step.Copy)
            {
                yield return(RequestCopy());
            }

            if (this.Step == Step.Coping)
            {
                var path     = _savePath + Versions.Filename + ".tmp";
                var versions = Versions.LoadVersions(path);
                var basePath = GetStreamingAssetsPath() + "/";
                yield return(UpdateCopy(versions, basePath));

                this.Step = Step.Versions;
            }

            if (this.Step == Step.Versions)
            {
                yield return(RequestVersions());
            }

            if (this.Step == Step.Prepared)
            {
                OnMessage("正在检查版本信息...");
                var totalSize = _downloader.size;
                if (totalSize > 0)
                {
                    Debug.Log($"发现内容更新,总计需要下载 {Downloader.GetDisplaySize(totalSize)} 内容");
                    _downloader.StartDownload();
                    this.Step = Step.Download;
                }
                else
                {
                    OnComplete();
                }
            }
        }
Exemplo n.º 5
0
        private void Update()
        {
            switch (_step)
            {
            case Step.Wait:
                break;

            case Step.Version:
                _step = Step.Wait;
                OnMessage("正在获取版本信息...");
                if (!Directory.Exists(_savePath))
                {
                    Directory.CreateDirectory(_savePath);
                }
                if (Application.internetReachability == NetworkReachability.NotReachable)
                {
                    MessageBox.Show("提示", "请检查网络连接状态", "重试", "退出").onComplete = OnErrorAction;
                    return;
                }
                var request = Download(Versions.Filename);
                var oper    = request.SendWebRequest();
                oper.completed += delegate(AsyncOperation operation)
                {
                    if (!string.IsNullOrEmpty(request.error))
                    {
                        MessageBox.Show("提示", string.Format("获取服务器版本失败:{0}", request.error), "重试", "退出").onComplete = OnErrorAction;
                    }
                    else
                    {
                        try
                        {
                            Versions.serverVersion = Versions.LoadFullVersion(_savePath + Versions.Filename);
                            var newFiles = Versions.GetNewFiles(PatchId.Level1, _savePath);
                            if (newFiles.Count > 0)
                            {
                                foreach (var item in newFiles)
                                {
                                    _downloader.AddDownload(GetDownloadURL(item.name), item.name, _savePath + item.name, item.hash, item.len);
                                }
                                _step = Step.Prepared;
                            }
                            else
                            {
                                OnComplete();
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.LogException(e);
                            MessageBox.Show("提示", "版本文件加载失败", "重试", "退出").onComplete += OnErrorAction;
                        }
                    }
                };
                break;

            case Step.Prepared:
                OnMessage("正在检查版本信息...");
                _step = Step.Wait;
                var totalSize = _downloader.size;
                if (totalSize > 0)
                {
                    var tips = string.Format("发现内容更新,总计需要下载 {0} 内容", Downloader.GetDisplaySize(totalSize));
                    MessageBox.Show("提示", tips, "下载", "退出").onComplete += delegate(MessageBox.EventId id)
                    {
                        if (id == MessageBox.EventId.Ok)
                        {
                            _downloader.StartDownload();
                            _step = Step.Download;
                        }
                        else
                        {
                            Quit();
                        }
                    };
                }
                else
                {
                    OnComplete();
                }
                break;
            }
        }