少年修仙传客户端代码仓库
client_Wu Xijin
2019-01-24 a167343313406ca0d788a3250afaf6efbd40451d
5971  双进度条表现逻辑
2个文件已修改
73 ■■■■■ 已修改文件
Core/GameEngine/Login/Launch.cs 57 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Launch/LaunchWin.cs 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Core/GameEngine/Login/Launch.cs
@@ -123,18 +123,12 @@
    }
    float timer = 0f;
    float progressRateOfIncrease = 1f;
    float originalExpectTotalTime = -1f;
    float expectTotalTime = 0f;
    public float totalTime {
        get {
            return Mathf.Lerp(originalExpectTotalTime, expectTotalTime, Mathf.Clamp01(timer / expectTotalTime));
        }
    }
    Queue<LaunchTask> tasks = new Queue<LaunchTask>();
    LaunchTask currentTask = null;
    bool launchComplete = false;
    float surplusProgress = 0f;
    float surplusTime = 0f;
    void Start()
    {
@@ -182,7 +176,6 @@
        tasks.Enqueue(launchFadeOutTask);
        CalculateExpectTotalTime();
        originalExpectTotalTime = expectTotalTime;
    }
    void Update()
@@ -221,7 +214,8 @@
            else
            {
                timer += Time.deltaTime;
                var progress = progressInfo.totalProgress + progressRateOfIncrease * Time.deltaTime / totalTime;
                var progress = progressInfo.totalProgress + surplusProgress * (Time.deltaTime / surplusTime);
                progress = Mathf.Clamp(progress, 0, 0.95f);
                var partProgress = 0f;
                if (currentTask == null)
@@ -249,19 +243,13 @@
    void CalculateExpectTotalTime()
    {
        var time = timer;
        foreach (var item in tasks)
        {
            time += item.expectTime;
        surplusTime = 0f;
        foreach (var item in tasks)
        {
            surplusTime += item.expectTime;
        }
        expectTotalTime = time;
        if (originalExpectTotalTime <= 0f)
        {
            originalExpectTotalTime = expectTotalTime;
        }
        progressRateOfIncrease = (expectTotalTime - timer) / (originalExpectTotalTime - timer);
        surplusProgress = 1 - progressInfo.totalProgress;
    }
    public enum LaunchStage
@@ -780,6 +768,7 @@
        public override void End()
        {
            expectTime = timer;
            UILoader.LoadWindowAsync("LaunchBackGroundWin", null);
            DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
        }
@@ -863,9 +852,6 @@
            protected set { LocalSave.SetFloat("LaunchFadeOutTask_ExpectTime", value); }
        }
        bool launchBackGroundLoadedOk = false;
        bool openBackGround = false;
        public override void Begin()
        {
            m_CurrentStage = LaunchStage.Complete;
@@ -883,25 +869,13 @@
                launchWin.FadeOut();
            }
            UILoader.LoadWindowAsync("LaunchBackGroundWin",
                (bool ok, UnityEngine.Object @object) =>
                {
                    if (ok)
                    {
                        launchBackGroundLoadedOk = true;
                    }
                });
            WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
        }
        public override void End()
        {
            expectTime = timer;
            DebugEx.LogFormat("{0}执行时长:{1};", this.GetType().Name, timer);
            if (!openBackGround)
            {
                WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
            }
            var launchBackGroundWin = WindowCenter.Instance.Get<LaunchBackGroundWin>();
            launchBackGroundWin.transform.SetAsFirstSibling();
        }
@@ -913,15 +887,6 @@
                return;
            }
            timer += Time.deltaTime;
            if (!openBackGround)
            {
                if (launchBackGroundLoadedOk)
                {
                    WindowCenter.Instance.Open<LaunchBackGroundWin>();
                    openBackGround = true;
                }
            }
            if (timer >= expectTime)
            {
System/Launch/LaunchWin.cs
@@ -166,14 +166,18 @@
            else
            {
                var progressInfo = Launch.progressInfo;
                m_TotalProgressSlider.value = progressInfo.totalProgress;
                m_TotalProgress.text = StringUtility.Contact(Mathf.RoundToInt(progressInfo.totalProgress * 100), "%");
                if (progressInfo.stage == Launch.LaunchStage.DownLoad)
                {
                    if (m_PartProgressSlider.gameObject.activeInHierarchy)
                    {
                        m_PartProgressSlider.gameObject.SetActive(false);
                    }
                    if (m_TotalProgressSlider.gameObject.activeInHierarchy)
                    {
                        m_TotalProgressSlider.gameObject.SetActive(false);
                    }
                }
                else
@@ -183,6 +187,14 @@
                        m_PartProgressSlider.gameObject.SetActive(true);
                    }
                    if (!m_TotalProgressSlider.gameObject.activeInHierarchy)
                    {
                        m_TotalProgressSlider.gameObject.SetActive(true);
                    }
                    m_TotalProgressSlider.value = progressInfo.totalProgress;
                    m_TotalProgress.text = StringUtility.Contact(Mathf.RoundToInt(progressInfo.totalProgress * 100), "%");
                    m_PartProgressSlider.value = progressInfo.partProgress;
                    m_PartProgress.text = StringUtility.Contact(Mathf.RoundToInt(progressInfo.partProgress * 100), "%");
                }