Example #1
0
    // Update 每帧调用一次
    void Update()
    {
        if (ApplicationMgr._DoNotCheckVersion)
        {
            return;
        }

        if (!_needCheckVersion || _versionData == null)
        {
            return;
        }

        VersionData.VersionType eType = _versionData.VersionTypeToUpdate;
        if (eType != _eCurType)//状态发生变化时刷新
        {
            _eCurType = eType;
            UpdateUIByState(eType);
            _eLastType = eType;
        }
        else if (eType == VersionData.VersionType.Inner && _isDownloading)//正在下载内更资源时刷新
        {
            UpdateUIByState(eType);
        }
        else if (eType == VersionData.VersionType.Program && _isDownloading)//正在下载大版本安装包
        {
            UpdateUIByState(eType);
        }
    }
Example #2
0
 private void OnClickOKButton(GameObject go)
 {
     if (!_bLoadSDKManagerXML)
     {
         //下载SDKManager.xml
         Start();
     }
     else
     {
         //下载version.xml
         VersionData.VersionType eType = _versionData.VersionTypeToUpdate;
         if (eType == VersionData.VersionType.Inner)
         {
             _versionData.StartUpdateVersion();
             _isDownloading = true;
         }
         else if (eType == VersionData.VersionType.Program)
         {
             if (SDKManager.isAppStoreVersion())
             {
                 ObjectCInterface.openURL(SDKManager.PackageDownloadWeb);
             }
             else if (!string.IsNullOrEmpty(SDKManager.PackageDownloadWeb))
             {
                 Application.OpenURL(SDKManager.PackageDownloadWeb);
             }
             else if (!string.IsNullOrEmpty(SDKManager.PackageDownloadUrl))
             {
                 _bLoadPackageFailed = false;
                 JARUtilTools tools = GameSceneManager.uiCameraObj.GetComponent <JARUtilTools>();
                 if (tools != null)
                 {
                     string fileName = System.IO.Path.GetFileName(SDKManager.PackageDownloadUrl);
                     tools.asyncHttpDownloadFile(SDKManager.PackageDownloadUrl, false, "", fileName, 1000, transform.name);
                     _isDownloading = true;
                 }
             }
         }
         else if (eType == VersionData.VersionType.Error)
         {
             //重试,跳过确认。
             _versionData = new VersionData();
             tfBoxChecking.gameObject.SetActive(true);
             tfBoxLoading.gameObject.SetActive(false);
             _isDownloading = true;
             _versionData.StartUpdateVersion();
             _needCheckVersion = true;
         }
     }
 }
Example #3
0
    private void UpdateUIByState(VersionData.VersionType eType)
    {
        switch (eType)
        {
        case VersionData.VersionType.Checking:    //正在检测
            tfBoxChecking.gameObject.SetActive(true);
            tfBoxLoading.gameObject.SetActive(false);
            break;

        case VersionData.VersionType.None:    //无版本要更新,或已更新完成
            tfBoxChecking.gameObject.SetActive(false);
            tfBoxLoading.gameObject.SetActive(false);
            if (_eLastType == VersionData.VersionType.Inner)    //更新完成
            {
                tfBoxLoading.gameObject.SetActive(true);
                loadingTip.text      = "资源更新完成";//GameText.GetStr("updateFinish");
                sliderProgress.value = 1f;

                if (ClientNetwork._bLoginOut)
                {
                    //UIManager.DestroyWin(UIName.MAIN_CITY_WIN);
                    //UIManager.DestroyWin(UIName.MAIN_CITY_CENTER_WIN);
                    ApplicationMgr.KillSelf();    //销毁,让它重新加载配置文件
                    AssetManager.getInstance().ClearAll();
                    ConfigDataMgr.getInstance().ClearAll();
                    GameDataMgr.ClearAll();
                    MsgCallManager.RemoveAllCallback();
                    MsgCallManager.Dispose();
                    EventSystem.Dispose();
                }
                Invoke("OnUpdateVersionComplete", 0.5f);
            }
            else
            {
                //tfJuHuaLoading.gameObject.SetActive(true);
                //if (ClientNetwork._bLoginOut)//如果是註銷出來的
                //{
                //    UIManager.CreateWin(UIName.LOGIN_WIN);
                //    Invoke("DelayToHideVersionUpdate", 0.5f);
                //}
                //else//如果第一次登錄進來
                //{
                //    GameObject sceneObj = GameObject.Find("Scene");
                //    if (sceneObj)
                //    {
                //        StartUpScene startUpMono = sceneObj.GetComponent<StartUpScene>();
                //        if (startUpMono)
                //            startUpMono.StartUp();
                //    }
                //}
                sliderProgress.value = 0f;
                GameObject sceneObj = GameObject.Find("Scene");
                if (sceneObj)
                {
                    StartUpScene startUpMono = sceneObj.GetComponent <StartUpScene>();
                    if (startUpMono)
                    {
                        startUpMono.StartUp();
                    }
                }
            }
            break;

        case VersionData.VersionType.Inner:    //内更资源
            //tfJuHuaLoading.gameObject.SetActive(false);
            tfBoxChecking.gameObject.SetActive(false);
            tfBoxLoading.gameObject.SetActive(true);
            if (_isDownloading == false)                    //提示框
            {
                if (UtilTools.GetCurrentNetworkType() == 1) //wifi
                {
                    tfBoxChecking.gameObject.SetActive(false);
                    tfBoxLoading.gameObject.SetActive(true);
                    tfOKButton.gameObject.SetActive(true);
                    tfSlider.gameObject.SetActive(false);
                    OnClickOKButton(null);
                }
                else
                {
                    tfBoxChecking.gameObject.SetActive(false);
                    tfBoxLoading.gameObject.SetActive(true);
                    loadingTip.text = string.Format("当前非WIFI网络环境,是否继续下载更新包({0})?", GetVersionDataSize());    //"有新版本发布,快去下载吧";//GameText.GetStr("checkTip");
                    tfOKButton.gameObject.SetActive(true);
                    tfSlider.gameObject.SetActive(false);
                    OKButtonText.text = "确定";
                }
            }
            else    //刷进度
            {
                loadingTip.text      = string.Format("下载资源包(编号{0}):  {1}/{2}", GetDownloadingVersion(), GetLoadedSize(), GetVersionDataSize());
                sliderProgress.value = _versionData.GetUpdatePercent();
                tfOKButton.gameObject.SetActive(false);
                tfSlider.gameObject.SetActive(true);
            }
            OKButtonText.text = "更新";    //GameText.GetStr("update");
            break;

        case VersionData.VersionType.Program:    //更新程序版本

            //tfJuHuaLoading.gameObject.SetActive(false);
            if (_isDownloading == false)                                  //提示框
            {
                if (!string.IsNullOrEmpty(SDKManager.PackageDownloadWeb)) //跳网页
                {
                    tfBoxChecking.gameObject.SetActive(false);
                    tfBoxLoading.gameObject.SetActive(true);
                    loadingTip.text = "有新版本发布,快去下载吧";
                    tfOKButton.gameObject.SetActive(true);
                    tfSlider.gameObject.SetActive(false);
                    OKButtonText.text = "更新";
                }
                else if (!string.IsNullOrEmpty(SDKManager.PackageDownloadUrl))    //内部下载
                {
                    if (UtilTools.GetCurrentNetworkType() == 1)
                    {
                        tfBoxChecking.gameObject.SetActive(false);
                        tfBoxLoading.gameObject.SetActive(true);
                        tfOKButton.gameObject.SetActive(true);
                        tfSlider.gameObject.SetActive(false);
                        OnClickOKButton(null);
                    }
                    else
                    {
                        tfBoxChecking.gameObject.SetActive(false);
                        tfBoxLoading.gameObject.SetActive(true);
                        loadingTip.text = string.Format("当前非WIFI网络环境,是否继续下载版本包({0}M)?", VersionData._strPackageSize);    //"有新版本发布,快去下载吧";//GameText.GetStr("checkTip");
                        tfOKButton.gameObject.SetActive(true);
                        tfSlider.gameObject.SetActive(false);
                        OKButtonText.text = "确定";
                    }
                }
                else    //如果没指定更新地址, 就不强制更新.
                {
                    VersionData.ShowTipWhenInToGame = true;
                    UpdateUIByState(VersionData.VersionType.None);    //直接跳过, 在点"进入游戏"时,提示有新版本,请前往更新.
                    return;
                }
            }
            else    //刷内部下载进度
            {
                if (_bLoadPackageFailed)
                {
                    _isDownloading = false;
                    tfBoxChecking.gameObject.SetActive(false);
                    tfBoxLoading.gameObject.SetActive(true);
                    loadingTip.text = string.Format("{0}(错误码:{1})", _strbLoadPackageFailed_msg, _strLoadPackageFailed_code);
                    tfOKButton.gameObject.SetActive(true);
                    tfSlider.gameObject.SetActive(false);
                    OKButtonText.text = "重新下载";
                    return;
                }
                else if (_bLoadPackageComplete)
                {
                    loadingTip.text = string.Format("下载版本包完成,正在安装...");
                }
                else
                {
                    loadingTip.text = string.Format("下载版本包({0}):  {1:F}M / {2:F}M", VersionData._toLoadProgramVersion, loadedPackageSize, totalPackageSize);
                }
                sliderProgress.value = loadedPackageSize / totalPackageSize;
                tfOKButton.gameObject.SetActive(false);
                tfSlider.gameObject.SetActive(true);
            }
            break;

        case VersionData.VersionType.Error:    //更新出错
            VersionData.ErrorCode errorCode = _versionData.ErrorCodeData;
            tfBoxChecking.gameObject.SetActive(false);
            tfBoxLoading.gameObject.SetActive(true);
            loadingTip.text = string.Format("检测版本中断,请检查网络后重试。(错误码:{0})", errorCode);
            tfOKButton.gameObject.SetActive(true);
            tfSlider.gameObject.SetActive(false);
            OKButtonText.text = "确定";
            break;

        default:
            break;
        }
    }