
//// ------------------------------------------------------------------------------
////  <autogenerated>
////      This code was generated by a tool.
////      Mono Runtime Version: 2.0.50727.1433
//// 
////      Changes to this file may cause incorrect behavior and will be lost if 
////      the code is regenerated.
////  </autogenerated>
//// ------------------------------------------------------------------------------

//namespace MyGame
//{
//    using System.Collections;
//    using UnityEngine;
//    using UnityEngine.UI;
//    using UniRx;
//    using QFramework;

//    public class HotFixedPanelData : QFramework.UIPanelData
//    {
//    }
    
//    public partial class HotFixedPanel : QFramework.UIPanel
//    {
//        private float m_SumTime = 0;

//        protected override void ProcessMsg(int eventId, QFramework.QMsg msg)
//        {
            
//        }
        
//        protected override void OnInit(QFramework.IUIData uiData)
//        {
//            mData = uiData as HotFixedPanelData ?? new HotFixedPanelData();

//            HotPatchManager.Instance.Init(this);

//            HotFixedSlider.fillAmount = 0;
//            HotFixedInfoText.text = string.Empty;
//         //   HotFixedSliderText.text = string.Format("{0:F}M/S", 0);
//            HotPatchManager.Instance.ServerInfoError += ServerInfoError;
//            HotPatchManager.Instance.ItemError += ItemError;

////#if UNITY_EDITOR
//         //   StartOnFinish(); 
////#else
//        if (HotPatchManager.Instance.ComputeUnPackFile())
//        {
//                HotFixedSliderText.text = "初始化中.....";
//            HotPatchManager.Instance.StartUnackFile(()=> 
//            {
//                m_SumTime = 0;
//                HotFix();
//            });
//        }
//        else
//        {
//            HotFix();
//        }
////#endif

//            Observable.EveryUpdate()
//                .Subscribe(_ =>
//                {
//                    if (HotPatchManager.Instance.StartUnPack)
//                    {
//                        m_SumTime += Time.deltaTime;
//                        HotFixedSlider.fillAmount = HotPatchManager.Instance.GetUnpackProgress();
//                        //float speed = (HotPatchManager.Instance.AlreadyUnPackSize / 1024.0f) / m_SumTime;
//                        //HotFixedSliderText.text = string.Format("{0:F} M/S", speed);
//                    }

//                    if (HotPatchManager.Instance.StartDownload)
//                    {
//                        m_SumTime += Time.deltaTime;
//                        HotFixedSlider.fillAmount = HotPatchManager.Instance.GetProgress();
//                        float speed = (HotPatchManager.Instance.GetLoadSize() / 1024.0f) / m_SumTime;
//                        HotFixedSliderText.text = string.Format("{0:F} M/S", speed);
//                    }
//                }).AddTo(gameObject);


//        }
        
//        protected override void OnOpen(QFramework.IUIData uiData)
//        {
//        }
        
//        protected override void OnShow()
//        {
//        }
        
//        protected override void OnHide()
//        {
//        }
        
//        protected override void OnClose()
//        {
//            HotPatchManager.Instance.ServerInfoError -= ServerInfoError;
//            HotPatchManager.Instance.ItemError -= ItemError;
//        }

//        void ServerInfoError()
//        {
//            MainConfig.Instance.commonConfirm.Show("服务器列表获取失败", "服务器列表获取失败，请检查网络链接是否正常？尝试重新下载！", CheckVersion, Application.Quit);
//        }

//        void ItemError(string all)
//        {
//            MainConfig.Instance.commonConfirm.Show("资源下载失败", string.Format("{0}等资源下载失败，请重新尝试下载！", all), AnewDownload, Application.Quit);
//        }

//        void HotFix()
//        {
//            if (Application.internetReachability == NetworkReachability.NotReachable)
//            {
//                //提示网络错误，检测网络链接是否正常
//                MainConfig.Instance.commonConfirm.Show("网络链接失败", "网络链接失败，请检查网络链接是否正常？", () =>
//                { Application.Quit(); }, () => { Application.Quit(); });
//            }
//            else
//            {
//                CheckVersion();
//            }
//        }

//        void CheckVersion()
//        {
//            HotPatchManager.Instance.CheckVersion((hot) =>
//            {
//                if (hot)
//                {
//                    //提示玩家是否确定热更下载
//                    MainConfig.Instance.commonConfirm.Show("热更", string.Format("当前版本为{0},有{1:F}M大小热更包，是否确定下载？", HotPatchManager.Instance.CurVersion, HotPatchManager.Instance.LoadSumSize / 1024.0f), OnClickStartDownLoad, OnClickCancleDownLoad);
//                }
//                else
//                {
//                     StartOnFinish();
//                }
//            });
//        }


//        void OnClickStartDownLoad()
//        {
//            if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.Android)
//            {
//                if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
//                {
//                    MainConfig.Instance.commonConfirm.Show("下载确认", "当前使用的是手机流量，是否继续下载？", StartDownLoad, OnClickCancleDownLoad);
                 
//                }
//                else
//                {
//                    StartDownLoad();
//                }
//            }
//            else
//            {
//                StartDownLoad();
//            }
//        }

//        void OnClickCancleDownLoad()
//        {
//            Application.Quit();
//        }

//        /// <summary>
//        /// 正式开始下载
//        /// </summary>
//        void StartDownLoad()
//        {
       
//            MainConfig.Instance.commonConfirm.Hide();
//           HotFixedInfoText.text = "下载中...";
//            Info.gameObject.Show();

//            HotContenText.text = HotPatchManager.Instance.CurrentPatches.Des;
//            StartCoroutine(HotPatchManager.Instance.StartDownLoadAB(StartOnFinish));
//        }

//        /// <summary>
//        /// 下载完成回调，或者没有下载的东西直接进入游戏
//        /// </summary>
//        void StartOnFinish()
//        {
          
//            StartCoroutine(OnFinish());
//         //   new GameObject().AddComponent<Main>().isUpdate=true;
//        }

//        IEnumerator OnFinish()
//        {

//            yield return StartCoroutine(StartGame(HotFixedSlider,HotFixedSliderText));

//            HotPatchManager.Instance.ServerInfoError -= ServerInfoError;
//            HotPatchManager.Instance.ItemError -= ItemError;
//            Destroy(gameObject);
//        }

//        public IEnumerator StartGame(Image image, Text text)
//        {
//            image.fillAmount = 0;
//            yield return null;
//            text.text = "加载本地数据... ...";
//          //  AssetBundleManager.Instance.LoadAssetBundleConfig();
//            image.fillAmount = 0.1f;
//            yield return null;
//            //text.text = "加载dll... ...";
//            //ILRuntimeManager.Instance.Init();
//            image.fillAmount = 0.2f;
//            yield return null;
//            text.text = "加载数据表... ...";
//            //LoadConfiger();
//            image.fillAmount = 0.7f;
//            yield return null;
//            text.text = "加载配置... ...";
//            image.fillAmount = 0.9f;
//            yield return null;
//            text.text = "初始化地图... ...";
//           // GameMapManager.Instance.Init(this);
//            image.fillAmount = 1f;
//            yield return null;
//        }

     
//        void AnewDownload()
//        {
//            HotPatchManager.Instance.CheckVersion((hot) =>
//            {
//                if (hot)
//                {
//                    StartDownLoad();
//                }
//                else
//                {
//                    StartOnFinish();
//                }
//            });
//        }
//    }

   
//}

