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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
public class LoadingWin : UIBase
{
    protected int currentProgress = 0;
    protected int targetProgress = 0;
 
    // [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] Text m_BuildTime;
    [SerializeField] Text m_Version;
    // [SerializeField] Button m_UserHelp;
 
    protected List<Sprite> backGrounds = new List<Sprite>();
 
    protected float backGroundTimer = 0f;
    protected int backGroundIndex = 0;
 
    protected override void InitComponent()
    {
        base.InitComponent();
 
        if (Application.isEditor)
        {
            if (m_BackGround.overrideSprite == null)
            {
                var sprite = BuiltInLoader.LoadSprite("Launch_1");
                m_BackGround.overrideSprite = sprite;
            }
        }
        else
        {
            if (backGrounds.Count <= 0)
            {
                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();
        currentProgress = targetProgress = 0;
        Refresh();
        //打包版本 + 功能版本 + 语言ID
        m_Version.text = LoginManager.Instance.GetVersionStr();
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
    }
 
    public override void Refresh()
    {
        base.Refresh();
        UpdateProgress();
    }
 
    public void SetProgress(float value, bool directly = false)
    {
        if (directly)
        {
            currentProgress = targetProgress = Mathf.Min((int)(value * 100), 100);
            UpdateProgress();
        }
        else
        {
            targetProgress = Mathf.Min((int)(value * 100), 100);
        }
    }
 
    protected void UpdateProgress()
    {
        // Debug.LogErrorFormat("cur : {0}  /  target {1}", currentProgress, targetProgress);
        if (currentProgress < targetProgress)
        {
            currentProgress = (int)Mathf.Lerp(currentProgress, targetProgress, 0.1f);
            m_TotalProgressSlider.value = currentProgress / 100f;
            m_PartProgressSlider.value = currentProgress / 100f;
        }
        else
        {
            m_TotalProgressSlider.value = currentProgress / 100f;
            m_PartProgressSlider.value = currentProgress / 100f;
        }
        CopiedLogic_UpdateProgress();
    }
 
    private void CopiedLogic_UpdateProgress()
    {
        //  暂留接口
 
        //  好像都不应该在这里写东西了
        //  m_TotalProgressSlider跟m_PartProgressSlider都有自己新的逻辑
        //  m_StageDescription有固定的文字
 
        //  iOS如果不是download那也都是隐藏的 这里肯定不会有download的 所以就不搬了
    }
 
    protected void LateUpdate()
    {
        UpdateProgress();
        CopiedLogic_LateUpdate();
    }
 
    private void CopiedLogic_LateUpdate()
    {
        backGroundTimer += Time.deltaTime;
        if (backGroundTimer >= 3f)
        {
            backGroundTimer -= 3f;
            if (backGrounds.Count > 1)
            {
                m_BackGround.overrideSprite = backGrounds[(++backGroundIndex) % backGrounds.Count];
            }
 
            //  考虑在这里做这个描述的切换 或者根据图片来做提示词
            // m_StageDescription.text = "";
        }
    }
 
    public void SetData(LaunchWinData _launchWinData)
    {
        backGroundTimer = _launchWinData.backGroundTimer;
        backGroundIndex = _launchWinData.backGroundIndex;
        m_BackGround.overrideSprite = _launchWinData.sprite;
        backGrounds = _launchWinData.sprites;
        m_StageDescription.text = Language.GetFromLocal(44);//最后Completed一定是这个 考虑要不要塞入LaunchWinData..
    }
}