少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, May 23, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using vnxbqy.UI;
 
namespace vnxbqy.UI
{
 
    public class InGameDownLoadProgress : MonoBehaviour
    {
        [SerializeField] Image m_ProgressSlider;
        [SerializeField] Text m_ProgressText;
        [SerializeField] Button m_ViewDownLoad;
 
        private void Awake()
        {
            if (!InGameDownLoad.Instance.hasReward
                   && InGameDownLoad.Instance.completeDownLoadAccount == PlayerDatas.Instance.baseData.AccID)
            {
                m_ProgressText.SetActive(true);
                m_ProgressText.text = "100%";
                this.SetActive(true);
            }
            else if (InGameDownLoad.Instance.dominantState != InGameDownLoad.Dominant.None)
            {
                this.SetActive(true);
                m_ProgressText.SetActive(true);
                if (InGameDownLoad.Instance.state != InGameDownLoad.State.Completed)
                {
                    m_ProgressText.text = "100%";
                }
                else
                {
                    var progress = Mathf.RoundToInt(InGameDownLoad.Instance.progress * 100);
                    m_ProgressText.text = StringUtility.Contact(progress, "%");
                }
            }
            else
            {
                this.SetActive(false);
            }
 
            InGameDownLoad.Instance.downLoadStateChangeEvent += OnDownLoadStateChange;
            InGameDownLoad.Instance.dominantDownLoadEvent += OnDownLoadDominantStateChange;
            m_ViewDownLoad.AddListener(OpenInGameDownloadWin);
        }
 
        private void OnEnable()
        {
            UpdateDownLoadProgress();
            GlobalTimeEvent.Instance.secondEvent += OnPerSecond;
        }
 
        private void OnDisable()
        {
            GlobalTimeEvent.Instance.secondEvent -= OnPerSecond;
        }
 
        private void OnDestroy()
        {
            m_ViewDownLoad.RemoveAllListeners();
        }
 
        private void OnDownLoadDominantStateChange(InGameDownLoad.Dominant _dominant)
        {
            UpdateDownLoadProgress();
            this.SetActive(InGameDownLoad.Instance.dominantState != InGameDownLoad.Dominant.None);
        }
 
        private void OnDownLoadStateChange(InGameDownLoad.State _step)
        {
            switch (_step)
            {
                case InGameDownLoad.State.Completed:
                    this.SetActive(false);
                    break;
                case InGameDownLoad.State.None:
                case InGameDownLoad.State.Prepared:
                case InGameDownLoad.State.DownLoad:
                    if (InGameDownLoad.Instance.dominantState != InGameDownLoad.Dominant.None)
                    {
                        UpdateDownLoadProgress();
                        this.SetActive(true);
                    }
                    else
                    {
                        this.SetActive(false);
                    }
 
                    m_ProgressText.SetActive(true);
                    break;
                case InGameDownLoad.State.Award:
                    this.SetActive(true);
                    m_ProgressText.SetActive(true);
                    m_ProgressText.text = "100%";
                    break;
            }
        }
 
        private void OnPerSecond()
        {
            UpdateDownLoadProgress();
        }
 
        private void UpdateDownLoadProgress()
        {
            m_ProgressSlider.fillAmount = InGameDownLoad.Instance.progress;
            if (m_ProgressText != null)
            {
                if (InGameDownLoad.Instance.state == InGameDownLoad.State.Award)
                {
                    m_ProgressText.text = "100%";
                }
                else
                {
                    var progress = Mathf.RoundToInt(InGameDownLoad.Instance.progress * 100);
                    m_ProgressText.text = StringUtility.Contact(Mathf.Clamp(progress, 0, 99), "%");
                }
            }
        }
 
        private void OpenInGameDownloadWin()
        {
            switch (InGameDownLoad.Instance.state)
            {
                case InGameDownLoad.State.DownLoad:
                case InGameDownLoad.State.None:
                case InGameDownLoad.State.Pause:
                case InGameDownLoad.State.Prepared:
                    WindowCenter.Instance.Open<InGameDownLoadWin>();
                    break;
                case InGameDownLoad.State.Award:
                    WindowCenter.Instance.Open<InGameDownLoadWin>();
                    break;
                case InGameDownLoad.State.Completed:
                    break;
            }
 
        }
 
    }
 
}