少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, January 02, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System;
 
 
namespace vnxbqy.UI
{
 
    public class FindPreciousBossBriefInfoBehaviour : AutoSelectScrollItem
    {
 
        [SerializeField] protected float m_SelectedShifting = 6f;
        [SerializeField] protected CanvasGroup m_CanvasGroup;
        [SerializeField] protected Button m_Select;
        [SerializeField] protected RectTransform m_Content;
        [SerializeField] protected Image m_BackGround;
        [SerializeField] protected Transform m_Selected;
        [SerializeField] protected ImageEx m_Portrait;
        [SerializeField] protected TextEx m_BossName;
        [SerializeField] protected TextEx m_BossLevel;
        [SerializeField] protected RectTransform m_RealmContainer;
        [SerializeField] protected Image m_Realm;
        [SerializeField] protected RectTransform m_UnLockCondition;
        [SerializeField] protected Image m_UnLockRealm;
        [SerializeField] protected TimerBehaviour m_CoolDown;
        [SerializeField] protected Transform m_RefreshAtOnce;
        [SerializeField] protected Material m_NormalMaterial;
        [SerializeField] protected Material m_GrayMaterial;
        [SerializeField] protected FontColorSizeConfig m_BossNameFontConfig;
        [SerializeField] protected FontColorSizeConfig m_BossLevelFontConfig;
 
        protected int bossId = 0;
        protected virtual int selectedBossId {
            get;
            set;
        }
 
        InteractorableState m_InteractorableState;
        protected virtual InteractorableState interactorableState {
            get { return m_InteractorableState; }
            set { m_InteractorableState = value; }
        }
 
        protected virtual bool isRebornRightNow {
            get {
                if (!findPreciousModel.IsBossUnlock(bossId))
                {
                    return false;
                }
 
                FindPreciousModel.BossInfo bossInfo = null;
                if (!findPreciousModel.TryGetBossInfo(bossId, out bossInfo))
                {
                    return false;
                }
 
                return !findPreciousModel.IsBossAlive(bossId) && TimeUtility.ServerNow > bossInfo.refreshTime;
            }
        }
 
        protected virtual bool isUnLocked {
            get { return findPreciousModel.IsBossUnlock(bossId); }
        }
 
        protected FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
 
        public override void Display(object _data)
        {
            base.Display(_data);
            bossId = (int)_data;
            var bossInfoQuery = m_RefreshAtOnce.AddMissingComponent<RebornRightNowBossInfoQuery>();
            bossInfoQuery.bossId = bossId;
            findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe;
            findPreciousModel.bossSubscribeChangeEvent += OnSubscribe;
            findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate;
            findPreciousModel.bossInfoUpdateEvent += OnBossInfoUpdate;
        }
 
        public override void Dispose()
        {
            base.Dispose();
            findPreciousModel.bossSubscribeChangeEvent -= OnSubscribe;
            findPreciousModel.bossInfoUpdateEvent -= OnBossInfoUpdate;
        }
 
        protected virtual void DrawBossBaseInfo(string icon, string name, int level, int realm)
        {
            m_Portrait.SetSprite(icon);
            m_Portrait.SetNativeSize();
            this.m_BossName.text = name;
            m_BossLevel.text = Language.Get("Z1024", level);
 
            m_RealmContainer.SetActive(isUnLocked);
            m_UnLockCondition.SetActive(!isUnLocked);
            if (!isUnLocked)
            {
                var unLockRealm = findPreciousModel.GetBossUnLockRealm(bossId);
                var config = RealmConfig.Get(unLockRealm);
                m_UnLockRealm.SetSprite(config.Img);
            }
            else
            {
                if (m_Realm != null && m_RealmContainer != null)
                {
                    if (realm > 0 && RealmConfig.Has(realm))
                    {
                        m_RealmContainer.SetActive(true);
                        var realmConfig = RealmConfig.Get(realm);
                        if (realmConfig != null)
                        {
                            m_Realm.SetSprite(realmConfig.Img);
                        }
                    }
                    else
                    {
                        m_RealmContainer.SetActive(false);
                    }
                }
            }
        }
 
        private void Awake()
        {
            m_Select.AddListener(SelectBoss);
        }
 
        private void SelectBoss()
        {
            //autoSelectScroll.TrySelectData(bossId);
            selectedBossId = bossId;
        }
 
        protected virtual void OnSubscribe(int _bossId)
        {
            if (bossId != _bossId)
            {
                return;
            }
 
        }
 
        protected virtual void UpdateBossPortrait(InteractorableState _state)
        {
            var isGray = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.DieOrLockedUnSelected;
            m_BackGround.material = isGray ? m_GrayMaterial : m_NormalMaterial;
            m_Portrait.material = isGray ? m_GrayMaterial : m_NormalMaterial;
        }
 
        protected virtual void UpdateBossRebornCoolDown(bool _isUnLocked)
        {
            if (_isUnLocked)
            {
                FindPreciousModel.BossInfo bossInfo;
                if (findPreciousModel.TryGetBossInfo(bossId, out bossInfo) && !bossInfo.IsBossAlive())
                {
                    if (TimeUtility.ServerNow > bossInfo.refreshTime)
                    {
                        m_CoolDown.SetActive(false);
                    }
                    else
                    {
                        m_CoolDown.Begin((int)(bossInfo.refreshTime - TimeUtility.ServerNow).TotalSeconds, OnBossCoolDownCompleted);
                    }
                }
                else
                {
                    m_CoolDown.SetActive(false);
                }
            }
            else
            {
                m_CoolDown.SetActive(false);
            }
        }
 
        protected void UpdateBossNameLevelFont(InteractorableState _state)
        {
            var selected = _state == InteractorableState.DieOrLockedSelected || _state == InteractorableState.NormalSelected;
            m_Content.anchoredPosition = selected ? new Vector2(m_SelectedShifting, 0) : Vector2.zero;
            if (m_CanvasGroup != null)
            {
                m_CanvasGroup.alpha = selected ? 1 : 0.8f;
            }
 
            m_Selected.SetActive(selected);
 
            var fontPattern = string.Empty;
            switch (_state)
            {
                case InteractorableState.NormalUnSelected:
                    fontPattern = "NormalUnSelected";
                    break;
                case InteractorableState.NormalSelected:
                    fontPattern = "NormalSelected";
                    break;
                case InteractorableState.DieOrLockedSelected:
                    fontPattern = "DieOrLockedSelected";
                    break;
                case InteractorableState.DieOrLockedUnSelected:
                    fontPattern = "DieOrLockedUnSelected";
                    break;
            }
 
            var nameFontColorSize = m_BossNameFontConfig.GetColorSize(fontPattern);
            var levelFontColorSize = m_BossLevelFontConfig.GetColorSize(fontPattern);
            m_BossName.color = nameFontColorSize.color;
            m_BossName.fontSize = nameFontColorSize.fontSize;
            m_BossLevel.color = levelFontColorSize.color;
            m_BossLevel.fontSize = levelFontColorSize.fontSize;
        }
 
        protected virtual void OnBossInfoUpdate(int _bossId)
        {
            if (bossId != _bossId)
            {
                return;
            }
 
            UpdateBossRebornCoolDown(isUnLocked);
            UpdateBossPortrait(interactorableState);
        }
 
        protected virtual void OnBossCoolDownCompleted()
        {
            UpdateBossPortrait(interactorableState);
        }
 
        protected virtual void LateUpdate()
        {
            //if (autoSelectScroll.autoSelectable && selectedBossId != bossId && bossId > 0)
            //{
            //    if (Mathf.Abs(centerSign.position.y - rectTransform.position.y) * 100f < rectTransform.rect.height * 0.45f)
            //    {
            //        selectedBossId = bossId;
            //    }
            //}
 
            if (m_RefreshAtOnce != null)
            {
                if (isRebornRightNow && !m_RefreshAtOnce.gameObject.activeInHierarchy)
                {
                    m_RefreshAtOnce.SetActive(true);
                }
                else if (!isRebornRightNow && m_RefreshAtOnce.gameObject.activeInHierarchy)
                {
                    m_RefreshAtOnce.SetActive(false);
                }
            }
        }
 
        public enum InteractorableState
        {
            NormalSelected,
            NormalUnSelected,
            DieOrLockedSelected,
            DieOrLockedUnSelected,
        }
 
    }
 
}