少年修仙传客户端代码仓库
client_linchunjie
2018-08-20 5e5551e8e7630f816a68c7bbe554a7e0bfa8705f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, September 05, 2017
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class LaunchWin : Window
    {
        [SerializeField] SmoothSlider m_ProgressSlider;
        [SerializeField] Text m_Progress;
        [SerializeField] Text m_BuildTime;
        [SerializeField] Text m_Version;
 
        bool assetBuildTimeShowed = false;
 
        string stepDescription = string.Empty;
 
        float refProgress = 0f;
        float behaviourProgress = 0f;
        float trueProgress = 0f;
 
        float timer = 0.1f;
        float interval = 0.1f;
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
        }
 
        protected override void OnPreOpen()
        {
            refProgress = 0f;
            behaviourProgress = 0f;
            trueProgress = 0f;
            m_ProgressSlider.ResetValue(0f);
 
            m_Version.text = StringUtility.Contact(VersionConfig.Get().version, "_", VersionConfig.Get().buildIndex);
            if (VersionConfig.Get().debugVersion)
            {
                m_BuildTime.text = VersionConfig.Get().buildTime;
            }
            else
            {
                m_BuildTime.text = "";
            }
 
            m_Progress.text = StringUtility.Contact(0, "%");
 
            UpdateLoadingProgress(Launch.currentStage, Launch.progress);
 
            Launch.progressEvent += UpdateLoadingProgress;
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            Launch.progressEvent -= UpdateLoadingProgress;
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void UpdateLoadingProgress(Launch.LaunchStage _stage, float _progress)
        {
            trueProgress = Mathf.Max(_progress, behaviourProgress);
            switch (_stage)
            {
                case Launch.LaunchStage.AssetCopy:
                    stepDescription = Language.GetFromLocal(14);
                    break;
                case Launch.LaunchStage.ClientVersion:
                    stepDescription = Language.GetFromLocal(15);
                    break;
                case Launch.LaunchStage.DownLoad:
                    stepDescription = Language.GetFromLocal(16);
                    break;
                case Launch.LaunchStage.ConfigLoad:
                    stepDescription = Language.GetFromLocal(17);
                    break;
            }
 
        }
 
        protected override void LateUpdate()
        {
            base.LateUpdate();
 
            if (trueProgress > 0.9599f)
            {
                behaviourProgress = Mathf.Clamp01(behaviourProgress + Time.deltaTime * 0.2f);
            }
            else
            {
                behaviourProgress = Mathf.SmoothDamp(behaviourProgress, trueProgress, ref refProgress, 0.2f);
            }
 
            m_ProgressSlider.value = behaviourProgress;
            m_Progress.text = StringUtility.Contact(stepDescription, Mathf.RoundToInt(behaviourProgress * 100), "%");
 
            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());
            }
        }
 
 
    }
}