//-------------------------------------------------------- 
 | 
//    [Author]:           玩个游戏 
 | 
//    [  Date ]:           Tuesday, September 05, 2017 
 | 
//-------------------------------------------------------- 
 | 
  
 | 
using System; 
 | 
using System.Collections; 
 | 
using System.Collections.Generic; 
 | 
using UnityEngine; 
 | 
using UnityEngine.UI; 
 | 
  
 | 
  
 | 
  
 | 
    public class LaunchWin : UIBase 
 | 
    { 
 | 
        // [SerializeField] UIAlphaTween m_AlphaTween; 
 | 
        // [SerializeField] Image m_BackGround; 
 | 
        [SerializeField] RectTransform m_AndroidProgressContainer; 
 | 
        [SerializeField] RectTransform m_NetworkContainer; 
 | 
        [SerializeField] SmoothSlider m_PartProgressSlider; 
 | 
        [SerializeField] SmoothSlider m_TotalProgressSlider; 
 | 
        [SerializeField] Text m_StageDescription; 
 | 
        [SerializeField] RectTransform m_IosProgressContainer; 
 | 
        [SerializeField] Text m_IosProgressTip; 
 | 
        [SerializeField] Text m_BuildTime; 
 | 
        [SerializeField] Text m_Version; 
 | 
  
 | 
        bool assetBuildTimeShowed = false; 
 | 
  
 | 
        LaunchStage showStage = LaunchStage.None; 
 | 
        int showStep = 0; 
 | 
        string stepDescription = string.Empty; 
 | 
  
 | 
        float backGroundTimer = 0f; 
 | 
        int backGroundIndex = 0; 
 | 
        List<Sprite> backGrounds = new List<Sprite>(); 
 | 
  
 | 
        int AllTimes = 0; 
 | 
        int WaitSeconds = 0; 
 | 
        bool ShowCircleView = false; 
 | 
        float TempCheck = 0; 
 | 
        protected override void InitComponent() 
 | 
        { 
 | 
            base.InitComponent(); 
 | 
            // m_BackGround.preserveAspect = true; 
 | 
            // if (Application.isEditor) 
 | 
            // { 
 | 
            //     var sprite = BuiltInLoader.LoadSprite("Launch_1"); 
 | 
            //     m_BackGround.overrideSprite = sprite; 
 | 
            // } 
 | 
            // else 
 | 
            // { 
 | 
            //     for (var i = 0; i < 3; i++) 
 | 
            //     { 
 | 
            //         var sprite = BuiltInLoader.LoadSprite(StringUtility.Contact("Launch_", i + 1)); 
 | 
            //         if (sprite != null) 
 | 
            //         { 
 | 
            //             backGrounds.Add(sprite); 
 | 
            //         } 
 | 
            //     } 
 | 
  
 | 
            //     m_BackGround.overrideSprite = backGrounds[0]; 
 | 
            // } 
 | 
  
 | 
  
 | 
        } 
 | 
  
 | 
        protected override void OnPreOpen() 
 | 
        { 
 | 
            base.OnPreOpen(); 
 | 
            backGroundTimer = 0f; 
 | 
            backGroundIndex = 0; 
 | 
            if (m_TotalProgressSlider != null) 
 | 
            { 
 | 
                m_TotalProgressSlider.ResetValue(0f); 
 | 
            } 
 | 
  
 | 
            // m_AlphaTween.SetStartState(); 
 | 
  
 | 
            m_BuildTime.text = VersionConfig.Get().debugVersion ? VersionConfig.Get().buildTime : ""; 
 | 
  
 | 
            if (m_NetworkContainer != null) 
 | 
            { 
 | 
                m_NetworkContainer.SetActive(false); 
 | 
            }  
 | 
  
 | 
            var AppleCheck   = InitialFunctionConfig.Get("CheckTime").Numerical1; 
 | 
            var AndroidCheck = InitialFunctionConfig.Get("CheckTime").Numerical2; 
 | 
            var CheckAll = InitialFunctionConfig.Get("NetworkCheck").Numerical1; 
 | 
            AllTimes = int.Parse(CheckAll); 
 | 
            var CheckTime = InitialFunctionConfig.Get("NetworkCheck").Numerical2; 
 | 
            WaitSeconds = int.Parse(CheckTime); 
 | 
            ShowCircleView = false; 
 | 
            if (Application.platform == RuntimePlatform.IPhonePlayer && AppleCheck == "1") 
 | 
                ShowCircleView = true; 
 | 
            if (Application.platform == RuntimePlatform.Android && AndroidCheck == "1") 
 | 
                ShowCircleView = true; 
 | 
  
 | 
            if (ShowCircleView) 
 | 
            { 
 | 
                m_AndroidProgressContainer.SetActive(false); 
 | 
                m_IosProgressContainer.SetActive(true); 
 | 
                m_Version.text = string.Empty; 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                m_AndroidProgressContainer.SetActive(true); 
 | 
                m_IosProgressContainer.SetActive(false); 
 | 
                //打包版本 + 功能版本 + 语言ID 
 | 
                m_Version.text = LoginManager.Instance.GetVersionStr(); 
 | 
            } 
 | 
  
 | 
            if (m_StageDescription != null) 
 | 
            { 
 | 
                m_StageDescription.text = GetLaunchStageDescription(showStage, showStep); 
 | 
            } 
 | 
  
 | 
            UpdateProgress(); 
 | 
  
 | 
            if (m_TotalProgressSlider == null) 
 | 
            { 
 | 
                m_TotalProgressSlider = this.GetComponentInChildren<SmoothSlider>(true); 
 | 
            } 
 | 
        } 
 | 
  
 | 
        protected override void OnOpen() 
 | 
        { 
 | 
            base.OnOpen(); 
 | 
        } 
 | 
  
 | 
        protected override void OnPreClose() 
 | 
        { 
 | 
            base.OnPreClose(); 
 | 
        } 
 | 
  
 | 
        protected override void OnClose() 
 | 
        { 
 | 
            base.OnClose(); 
 | 
        } 
 | 
  
 | 
        public void FadeOut() 
 | 
        { 
 | 
            // m_AlphaTween.Play(); 
 | 
            CloseWindow(); 
 | 
        } 
 | 
  
 | 
        string GetLaunchStageDescription(LaunchStage _stage, int step) 
 | 
        { 
 | 
            switch (_stage) 
 | 
            { 
 | 
                case LaunchStage.SDKInit: 
 | 
                    return Language.GetFromLocal(36); 
 | 
                case LaunchStage.AssetCopy: 
 | 
                    return StringUtility.Contact(Language.GetFromLocal(37), "(", step, ")"); 
 | 
                case LaunchStage.AssetDecompress: 
 | 
                    return StringUtility.Contact(Language.GetFromLocal(38), "(", step, ")"); 
 | 
                case LaunchStage.ClientVersion: 
 | 
                    return Language.GetFromLocal(39); 
 | 
                case LaunchStage.CheckAsset: 
 | 
                    return Language.GetFromLocal(40); 
 | 
                case LaunchStage.DownLoad: 
 | 
                    return Language.GetFromLocal(41); 
 | 
                case LaunchStage.AssetBundleInit: 
 | 
                    return Language.GetFromLocal(42); 
 | 
                case LaunchStage.ConfigInit: 
 | 
                    return StringUtility.Contact(Language.GetFromLocal(43), "(", step, ")"); 
 | 
                case LaunchStage.Complete: 
 | 
                    return Language.GetFromLocal(44); 
 | 
                default: 
 | 
                    return ""; 
 | 
            } 
 | 
        } 
 | 
  
 | 
        protected void LateUpdate() 
 | 
        { 
 | 
            UpdateProgress(); 
 | 
  
 | 
            // backGroundTimer += Time.deltaTime; 
 | 
            // if (backGroundTimer >= 3f) 
 | 
            // { 
 | 
            //     backGroundTimer = 0f; 
 | 
            //     if (backGrounds.Count > 1) 
 | 
            //     { 
 | 
            //         m_BackGround.overrideSprite = backGrounds[(++backGroundIndex) % backGrounds.Count]; 
 | 
            //     } 
 | 
            // } 
 | 
  
 | 
            if (HttpBehaviour.ConnectAllTimes >= AllTimes && m_NetworkContainer != null) 
 | 
            { 
 | 
                TempCheck += Time.deltaTime; 
 | 
                m_NetworkContainer.SetActive(true); 
 | 
                if (TempCheck >= WaitSeconds) 
 | 
                { 
 | 
                    TempCheck = 0; 
 | 
                    m_NetworkContainer.SetActive(false); 
 | 
                    HttpBehaviour.ConnectAllTimes = 0; 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        private void OpenUserHelp() 
 | 
        { 
 | 
            // TODO YYL 
 | 
            // UIManager.Instance.OpenWindow<UserHelpWin>(); 
 | 
        } 
 | 
         
 | 
        private void UpdateProgress() 
 | 
        { 
 | 
            //if (Application.platform == RuntimePlatform.IPhonePlayer) 
 | 
            if(ShowCircleView) 
 | 
            { 
 | 
                m_IosProgressContainer.SetActive(LaunchInHot.progressInfo.stage != LaunchStage.DownLoad); 
 | 
                var remainder = ((int)Time.time) % 3; 
 | 
                var dot = remainder == 0 ? "." : remainder == 1 ? ".." : "..."; 
 | 
                m_IosProgressTip.text = StringUtility.Contact(Language.GetFromLocal(30), dot); 
 | 
            } 
 | 
            else 
 | 
            { 
 | 
                var progressInfo = LaunchInHot.progressInfo; 
 | 
  
 | 
                if (progressInfo.stage == LaunchStage.DownLoad) 
 | 
                { 
 | 
                    if (m_PartProgressSlider != null && m_PartProgressSlider.gameObject.activeInHierarchy) 
 | 
                    { 
 | 
                        m_PartProgressSlider.SetActive(false); 
 | 
                    } 
 | 
  
 | 
                    if (m_TotalProgressSlider != null && m_TotalProgressSlider.gameObject.activeInHierarchy) 
 | 
                    { 
 | 
                        m_TotalProgressSlider.SetActive(false); 
 | 
                    } 
 | 
                } 
 | 
                else 
 | 
                { 
 | 
                    if (m_PartProgressSlider != null && !m_PartProgressSlider.gameObject.activeInHierarchy) 
 | 
                    { 
 | 
                        m_PartProgressSlider.SetActive(true); 
 | 
                    } 
 | 
  
 | 
                    if (m_TotalProgressSlider != null && !m_TotalProgressSlider.gameObject.activeInHierarchy) 
 | 
                    { 
 | 
                        m_TotalProgressSlider.SetActive(true); 
 | 
                    } 
 | 
  
 | 
                    if (m_TotalProgressSlider != null) 
 | 
                    { 
 | 
                        m_TotalProgressSlider.value = progressInfo.totalProgress; 
 | 
                    } 
 | 
  
 | 
                    if (m_PartProgressSlider != null) 
 | 
                    { 
 | 
                        m_PartProgressSlider.value = progressInfo.partProgress; 
 | 
                    } 
 | 
                } 
 | 
  
 | 
                DisplayStageDescription(progressInfo.stage, progressInfo.step); 
 | 
  
 | 
                //if (!assetBuildTimeShowed && AssetVersionUtility.assetsBuildTime != DateTime.MinValue) 
 | 
                //{ 
 | 
                //    assetBuildTimeShowed = true; 
 | 
                //    var totalMinute = (int)(AssetVersionUtility.assetsBuildTime - new DateTime(2018, 1, 1)).TotalMinutes; 
 | 
                //    m_Version.text = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex, "_", totalMinute.ToString()); 
 | 
                //} 
 | 
            } 
 | 
  
 | 
        } 
 | 
  
 | 
        private void DisplayStageDescription(LaunchStage stage, int step) 
 | 
        { 
 | 
            if (showStage != stage || showStep != step) 
 | 
            { 
 | 
                showStage = stage; 
 | 
                showStep = step; 
 | 
                if (m_StageDescription != null) 
 | 
                { 
 | 
                    m_StageDescription.text = GetLaunchStageDescription(stage, step); 
 | 
                } 
 | 
            } 
 | 
        } 
 | 
  
 | 
        public LaunchWinData GetData() 
 | 
        { 
 | 
            return new LaunchWinData(){ 
 | 
                backGroundTimer = backGroundTimer, 
 | 
                backGroundIndex = backGroundIndex, 
 | 
                // sprite = m_BackGround.overrideSprite, 
 | 
                sprites = backGrounds, 
 | 
            }; 
 | 
        } 
 | 
  
 | 
    } 
 |