少年修仙传客户端代码仓库
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, April 22, 2019
//--------------------------------------------------------
 
using System;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using System.Text;
 
namespace vnxbqy.UI
{
    //渡劫界面
    // 1. 计算有几道天雷
    // 2. 过场云打开
    // 3. 播放天雷动画 第几道 - 雷击动画 - 飘血动画(进度条变化)
    public class RealmBreakWin : Window
    {
        [SerializeField] RawImage rawPlayer;
        [SerializeField] UIEffect guochangyun;
 
        [SerializeField] RectTransform tianleiWord;
        [SerializeField] Image numImage;
        [SerializeField] UIFrame leiJiFrame;
        [SerializeField] Text hurtText;
        [SerializeField] IntensifySmoothSlider expSlider;
        [SerializeField] Text expText; //战力
 
        int flashCount = 0;
        int currentFlash = 0;
        ulong hurtValue = 0;
        ulong curFightPointValue = 0;
        ulong maxFightPointValue = 0;
        RealmModel model { get { return ModelCenter.Instance.GetModel<RealmModel>(); } }
 
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
        }
 
        protected override void OnPreOpen()
        {
            leiJiFrame.SetActive(false);
            hurtText.SetActive(false);
            tianleiWord.SetActive(false);
            //3-10道天雷,跨大境界就多一次
            flashCount = Math.Min(PlayerDatas.Instance.baseData.realmLevel / 4 + 3, 9);
            //每道天雷伤害为 战力的 flashCount+1分之一
            hurtValue = PlayerDatas.Instance.baseData.FightPoint / (ulong)(flashCount + 1);
            curFightPointValue = maxFightPointValue = PlayerDatas.Instance.baseData.FightPoint;
            currentFlash = 1;
            Display();
            WholeAnimate();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            UI3DModelExhibition.Instance.StopShow();
        }
 
        protected override void OnAfterClose()
        {
        }
 
        //protected override void LateUpdate()
        //{
 
        //}
        #endregion
 
        void Display()
        {
            UI3DModelExhibition.Instance.ShowSitDownPlayer(rawPlayer, PlayerDatas.Instance.baseData.Job);
 
        }
 
        void WholeAnimate()
        {
            var squences = DOTween.Sequence();
            
            if (currentFlash == 1)
            {
                guochangyun.Play();
                guochangyun.target.GetAnimator().speed = 2f;
                expText.text = StringUtility.Contact(Language.Get("MainInterfacePanel_HeadPortraitTip_ZL"), Language.Get("BlessedLand036", curFightPointValue, maxFightPointValue));
                expSlider.value = 1;
                squences.AppendInterval(0.5f);
            }
 
            //天道字
            squences.AppendCallback(() =>
            {
                numImage.SetSprite("DujieNum" + currentFlash);
                tianleiWord.transform.localScale = Vector3.one * 0.4f;
                tianleiWord.SetActive(true);
            });
            squences.Append(tianleiWord.transform.DOScale(1, 0.2f));
            squences.AppendInterval(0.2f);
            //雷击播放一次
            squences.AppendCallback(() =>
            {
                tianleiWord.SetActive(false);
                leiJiFrame.SetLoopCount(1);
                leiJiFrame.SetActive(true);
                SoundPlayer.Instance.PlayUIAudio(859);
            });
            squences.AppendInterval(0.2f);
            // 进度条变化
            squences.AppendCallback(() =>
            {
                curFightPointValue = curFightPointValue - hurtValue;
                expText.text = StringUtility.Contact(Language.Get("MainInterfacePanel_HeadPortraitTip_ZL"), Language.Get("BlessedLand036", curFightPointValue, maxFightPointValue));
                expSlider.delay = 0;
                expSlider.value = (float)curFightPointValue / maxFightPointValue;
            });
 
            //飘血动画 
            squences.AppendCallback(() =>
            {
                hurtText.SetActive(true);
                hurtText.text = ConvertToArtFont("EnemyAttack", hurtValue + (ulong)UnityEngine.Random.Range(0, (int)hurtValue / (flashCount * 2)));
                hurtText.transform.localPosition = new Vector3(0, -100, 0);
                hurtText.transform.localScale = Vector3.one * 0.5f;
            });
            squences.Append(hurtText.transform.DOScale(2f, 0.1f));
            squences.Join(hurtText.transform.DOLocalMoveY(60, 0.1f));
            squences.Join(hurtText.DOFade(1, 0.1f));
            squences.Append(hurtText.transform.DOPunchPosition(new Vector3(0,30,0), 0.3f, 10));
            squences.AppendInterval(0.1f);
            squences.Append(hurtText.transform.DOScale(0.5f, 0.2f));
            squences.Join(hurtText.DOFade(0, 0.2f));
            //继续下一次到天雷结束
            squences.onComplete = () =>
            {
                currentFlash++;
                if (currentFlash <= flashCount)
                {
                    WholeAnimate();
                }
                else
                {
                    Close();
                    WindowCenter.Instance.Open<RealmPromoteWin>();
                }
            };
        }
 
        string ConvertToArtFont(string _key, ulong _num)
        {
            var config = DamageNumConfig.Get(_key);
            var stringBuild = new StringBuilder();
            stringBuild.Append((char)config.minus);
 
            var chars = _num.ToString();
            for (var i = 0; i < chars.Length; i++)
            {
                var numChar = config.nums[(int)chars[i] - 48];
                if (numChar > 0)
                {
                    stringBuild.Append((char)numChar);
                }
            }
 
            return stringBuild.ToString();
        }
    }
 
}