少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 11997ece0dc4980eba3dd8889d37adb8376e14cb
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
 
using System;
using System.Text;
using System.Text.RegularExpressions;
 
namespace Snxxz.UI
{
    public class RolePanel : Window
    {
        [SerializeField] FunctionButtonGroup buttonGroup;
        [SerializeField] FunctionButton functionButtonRole;
        [SerializeField] FunctionButton functionButtonMagician;
        [SerializeField] FunctionButton m_ReikiRoot;
        [SerializeField] FunctionButton m_GatherSoul;
        [SerializeField] FunctionButton m_FashionDress;
 
        [SerializeField] RectTransform m_RoleInfoRt;
        [SerializeField] Text m_PropertyAtk;
        [SerializeField] Text m_PropertyHp;
        [SerializeField] Text m_PropertyHit;
        [SerializeField] Text m_PropertyDef;
        [SerializeField] Text m_PropertyDodge;
        [SerializeField] Text m_PropertyLuck;
 
        [SerializeField] Text m_PropertyAtkSpeed;
        [SerializeField] Text m_PropertyMoveSpeed;
        [SerializeField] Text m_PropertyRealHurt;
        [SerializeField] Text m_PropertyRealDef;
        [SerializeField] Text m_PropertyExtraHurt;
        [SerializeField] Text m_PropertyReduceHurt;
        [SerializeField] Text m_PropertyCritOdd;
        [SerializeField] Text m_PropertyCritHurt;
        [SerializeField] Text m_PropertyCritHurtOdd;
        [SerializeField] Text m_PropertyCritHitHurt;
        [SerializeField] Text m_PlayerExp;
        [SerializeField] Text m_PlayerLv;
        [SerializeField] Text m_PlayerName;
        [SerializeField] Text m_PlayerFightPower;
        [SerializeField] RawImage m_PlayerShowModel;
        [SerializeField] RectTransform m_ContainerExp;
        [SerializeField] Slider m_ExpSlider;
        [SerializeField] Text m_WorldExp;
        [SerializeField] Button m_PlayerPropertyBtn;
        [SerializeField] Button m_TitleBtn;
        [SerializeField] Button m_RenameBtn;
        [SerializeField] Image m_RoleTitleIcon;
        [SerializeField] Image m_RoleRealmIcon;
        [SerializeField] Button m_LeftBtn;
        [SerializeField] Button m_RightBtn;
        [SerializeField] Button m_CloseBtn;
        [SerializeField] Button m_Btn_Elixir;
 
        RoleModel m_Model;
        RoleModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<RoleModel>());
            }
        }
 
        TitleModel m_TitleModel;
        TitleModel titleModel
        {
            get
            {
                return m_TitleModel ?? (m_TitleModel = ModelCenter.Instance.GetModel<TitleModel>());
            }
        }
 
        PackModel packModel
        {
            get { return ModelCenter.Instance.GetModel<PackModel>(); }
        }
 
        private void OnRefreshTitle()
        {
            TitleData titleData = titleModel.GetTitleEquip();
            if (titleData != null && titleModel.IsTitleGain(titleData.id))
            {
                m_RoleTitleIcon.gameObject.SetActive(true);
                DienstgradConfig cfg = DienstgradConfig.Get(titleData.id);
                if (cfg != null)
                {
                    m_RoleTitleIcon.SetSprite(cfg.Image);
                }
            }
            else
            {
                m_RoleTitleIcon.gameObject.SetActive(false);
            }
        }
        private void OnRefreshRealm()
        {
            int realmlv = PlayerDatas.Instance.baseData.realmLevel;
            RealmConfig presentCfg = RealmConfig.Get(realmlv);
            if (presentCfg != null && presentCfg.Lv > 0)
            {
                m_RoleRealmIcon.SetSprite(presentCfg.Img);
                m_RoleRealmIcon.gameObject.SetActive(true);
            }
            else
            {
                m_RoleRealmIcon.gameObject.SetActive(false);
            }
        }
        private void OnRenameClick()
        {
            //SysNotifyMgr.Instance.ShowTip("JadeInvestmentLimit1");
            WindowCenter.Instance.Open<RoleRenameWin>();
        }
 
        private void OnElixirClick()
        {
            //WindowCenter.Instance.Open<RoleElixirTipWin>();
        }
        private void OnDesignationClick()
        {
            if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Title))
            {
                WindowCenter.Instance.Open<RoleTitle>();
            }
            else
            {
                FuncOpen.Instance.ProcessorFuncErrorTip((int)FuncOpenEnum.Title);
            }
        }
        private void OnAttrExplainClick()
        {
            WindowCenter.Instance.Open<RoleAttrWin>();
        }
 
        private void OnRefreshPlayerInfo(PlayerDataType refreshType)
        {
            switch (refreshType)
            {
                case PlayerDataType.FightPower:
                    m_PlayerFightPower.text = PlayerDatas.Instance.baseData.FightPoint.ToString();
                    break;
                case PlayerDataType.MAXATK:
                case PlayerDataType.MINATK:
                case PlayerDataType.MaxHP:
                case PlayerDataType.HIT:
                case PlayerDataType.DEF:
                case PlayerDataType.Miss:
                case PlayerDataType.LuckValue:
                    {
                        OnUpdateBasicAttr();
                    }
                    break;
                case PlayerDataType.RealmLevel:
                    {
                        OnRefreshRealm();
                    }
                    break;
                case PlayerDataType.LV:
                case PlayerDataType.TotalExp:
                case PlayerDataType.ExpPoint:
                    {
                        OnUpdateLvExp();
                        OnRefreshWorldLv();
                    }
                    break;
            }
        }
 
        private void RefreshPlayerInfoEvent()
        {
            OnUpdateSpecialAttr();
        }
 
        void InitRole()
        {
            OnUpdateBasicAttr();
            OnUpdateSpecialAttr();
            OnUpdateLvExp();
            m_PlayerFightPower.text = PlayerDatas.Instance.baseData.FightPoint.ToString();
            DisplayModel();
            OnRefreshRealm();
            OnRefreshWorldLv();
        }
 
        void DisplayModel()
        {
            UI3DModelExhibition.Instance.ShowPlayer(m_PlayerShowModel, PlayerDatas.Instance.baseData.Job);
        }
 
        void OnUpdateLvExp()
        {
            int lv = PlayerDatas.Instance.baseData.LV;
            if (PlayerLVConfig.Get(lv + 1) == null)
            {
                m_ExpSlider.maxValue = 1;
                m_ExpSlider.minValue = 0;
                m_ExpSlider.value = 1;
                m_PlayerExp.text = Language.Get("L1055");
            }
            else
            {
                m_ExpSlider.minValue = 0;
                m_ExpSlider.maxValue = PlayerLVConfig.GetExpByPlayerLv(lv);
                m_ExpSlider.value = (ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * 100000000;
                m_PlayerExp.text = string.Format("{0}/{1}", UIHelper.ReplaceLargeNum((ulong)PlayerDatas.Instance.baseData.TotalExp + (ulong)PlayerDatas.Instance.baseData.ExpPoint * 100000000), UIHelper.ReplaceLargeNum((ulong)PlayerLVConfig.GetExpByPlayerLv(lv)));
            }
            m_PlayerLv.text = Language.Get("Z1024", lv);
            m_PlayerName.text = PlayerDatas.Instance.baseData.PlayerName;
            OnRefreshTitle();
        }
 
        void OnUpdateBasicAttr()
        {
            m_PropertyAtk.text = StringUtility.Contact(ReplaceLargeNum((ulong)PlayerDatas.Instance.extersion.MINATK), "-", ReplaceLargeNum((ulong)PlayerDatas.Instance.extersion.MAXATK));
            m_PropertyHp.text = GetAttrStr(PropertyType.HP);
            m_PropertyHit.text = GetAttrStr(PropertyType.HIT);
            m_PropertyDef.text = GetAttrStr(PropertyType.DEF);
            m_PropertyDodge.text = GetAttrStr(PropertyType.MISS);
            m_PropertyLuck.text = GetAttrStr(PropertyType.Luck);
        }
 
        void OnUpdateSpecialAttr()
        {
            m_PropertyAtkSpeed.text = GetAttrStr(PropertyType.ATKSPEED);
            m_PropertyMoveSpeed.text = GetAttrStr(PropertyType.MoveSpeed);
            m_PropertyRealHurt.text = GetAttrStr(PropertyType.RealHurt);
            m_PropertyRealDef.text = GetAttrStr(PropertyType.RealResis);
            m_PropertyExtraHurt.text = GetAttrStr(PropertyType.AddHurt);
            m_PropertyReduceHurt.text = GetAttrStr(PropertyType.ReduceHurt);
            m_PropertyCritOdd.text = GetAttrStr(PropertyType.CritChance);
            m_PropertyCritHurt.text = GetAttrStr(PropertyType.CritHurt);
            m_PropertyCritHurtOdd.text = GetAttrStr(PropertyType.HeartHit);
            m_PropertyCritHitHurt.text = GetAttrStr(PropertyType.HeartHurt);
        }
 
        private string GetAttrStr(PropertyType type)
        {
            PlayerPropertyConfig cfg = PlayerPropertyConfig.Get((int)type);
            float value = UIHelper.GetPropertyValue(type);
            return StringUtility.Contact(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(value, cfg.ISPercentage)), cfg.ISPercentage == 1 ? "%" : string.Empty);
        }
 
        void OnDisableRole()
        {
            UI3DModelExhibition.Instance.StopShow();
        }
 
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            functionButtonRole.onClick.AddListener(OnFuncRole);
            functionButtonMagician.onClick.AddListener(OnFuncMagician);
            m_GatherSoul.onClick.AddListener(GatherSoul);
            m_ReikiRoot.onClick.AddListener(ReikiRoot);
            m_FashionDress.onClick.AddListener(OpenFashionDress);
            m_PlayerPropertyBtn.onClick.AddListener(OnAttrExplainClick);
            m_TitleBtn.onClick.AddListener(OnDesignationClick);
            m_RenameBtn.onClick.AddListener(OnRenameClick);
            m_Btn_Elixir.onClick.AddListener(OnElixirClick);
            m_LeftBtn.onClick.AddListener(buttonGroup.TriggerLast);
            m_RightBtn.onClick.AddListener(buttonGroup.TriggerNext);
            m_CloseBtn.onClick.AddListener(CloseClick);
        }
 
        private void ReikiRoot()
        {
            CloseChild();
            WindowCenter.Instance.Open<ReikiRootWin>();
            functionOrder = m_ReikiRoot.order;
        }
 
        private void GatherSoul()
        {
            CloseChild();
            WindowCenter.Instance.Open<GatherSoulWin>();
            functionOrder = m_GatherSoul.order;
        }
 
        private void OpenFashionDress()
        {
            CloseChild();
            WindowCenter.Instance.Open<FashionDressWin>();
            functionOrder = m_FashionDress.order;
        }
 
        private void OnFuncMagician()
        {
            CloseChild();
            WindowCenter.Instance.Open<MagicianWin>();
            functionOrder = functionButtonMagician.order;
        }
 
        private void OnFuncRole()
        {
            CloseChild();
            m_RoleInfoRt.gameObject.SetActive(true);
            InitRole();
            functionOrder = 0;
        }
 
        protected override void OnPreOpen()
        {
            PlayerDatas.Instance.playerDataUpdateEvent += OnUpdateLvExp;
            PlayerDatas.Instance.playerDataRefreshEvent += OnRefreshPlayerInfo;
            titleModel.OnRefreshGainTitle += OnRefreshTitle;
            PlayerDatas.Instance.worldLevelUpdateEvent += OnRefreshWorldLv;
            PlayerDatas.Instance.playerDataUpdateEvent += RefreshPlayerInfoEvent;
            packModel.refreshItemCountEvent += RefreshItemCountAct;
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            buttonGroup.TriggerByOrder(functionOrder);
        }
 
        protected override void OnAfterOpen()
        {
 
        }
        protected override void OnPreClose()
        {
        }
        protected override void OnAfterClose()
        {
            PlayerDatas.Instance.playerDataUpdateEvent -= OnUpdateLvExp;
            PlayerDatas.Instance.playerDataRefreshEvent -= OnRefreshPlayerInfo;
            titleModel.OnRefreshGainTitle -= OnRefreshTitle;
            PlayerDatas.Instance.worldLevelUpdateEvent -= OnRefreshWorldLv;
            packModel.refreshItemCountEvent -= RefreshItemCountAct;
            if (!WindowJumpMgr.Instance.IsJumpState)
            {
                WindowCenter.Instance.Open<MainInterfaceWin>();
            }
            PlayerDatas.Instance.playerDataUpdateEvent -= RefreshPlayerInfoEvent;
            CloseChild();
        }
 
        private void RefreshItemCountAct(PackType packType, int index, int arg3)
        {
            if (packType == PackType.Equip)
            {
                DisplayModel();
            }
        }
 
        private void OnRefreshWorldLv()
        {
            int limit = FuncOpenLVConfig.Get((int)FuncOpenEnum.WorldLv).LimitLV;
            if (PlayerDatas.Instance.baseData.LV >= limit)
            {
                m_WorldExp.gameObject.SetActive(true);
                m_WorldExp.text = Language.Get("WordExpText", PlayerDatas.Instance.worldLv, Mathf.FloorToInt(UIHelper.ReplacePercentage((int)PlayerDatas.Instance.worldExpRate, 2)) + "%");
            }
            else
            {
                m_WorldExp.gameObject.SetActive(false);
            }
        }
 
        private void CloseChild()
        {
            if (m_RoleInfoRt.gameObject.activeSelf)
            {
                OnDisableRole();
                m_RoleInfoRt.gameObject.SetActive(false);
            }
            var children = WindowConfig.Get().FindChildWindows("RolePanel");
            foreach (var window in children)
            {
                WindowCenter.Instance.Close(window);
            }
        }
 
        public StringBuilder m_StringBuilder = new StringBuilder();
 
        public string ReplaceLargeNum(float num)
        {
            m_StringBuilder.Length = 0;
            float hm = (float)Math.Round(num / 100000000, 2);
            if (hm >= 1)
            {
                int _value = (int)hm;
                var _length = 3 - _value.ToString().Length;
                _length = Mathf.Max(0, _length);
                if (_length > 0)
                {
                    hm = (float)Math.Round(num / 100000000, _length);
                }
                decimal _checkValue = ((decimal)hm * 1000 - _value * 1000) / 1000;
                var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
                m_StringBuilder.Append(hm.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
                m_StringBuilder.Append(Language.Get("L1070"));
                return m_StringBuilder.ToString();
            }
            float tt = (float)Math.Round(num / 10000, 2);
            if (tt >= 1)
            {
                int _value = (int)tt;
                var _length = 3 - _value.ToString().Length;
                if (_length > 0)
                {
                    tt = (float)Math.Round(num / 10000, _length);
                }
                _length = Mathf.Max(0, _length);
                decimal _checkValue = ((decimal)tt * 1000 - _value * 1000) / 1000;
                var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
                m_StringBuilder.Append(tt.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
                m_StringBuilder.Append(Language.Get("L1071"));
                return m_StringBuilder.ToString();
            }
            if (m_StringBuilder.Length == 0)
            {
                num = (float)Math.Round(num, 2);
                int _value = (int)num;
                var _length = 3 - _value.ToString().Length;
                if (_length > 0)
                {
                    num = (float)Math.Round(num, _length);
                }
                _length = Mathf.Max(0, _length);
                decimal _checkValue = ((decimal)num * 1000 - _value * 1000) / 1000;
                var _decimal = Mathf.Max(0, _checkValue.ToString().Length - 2);
                m_StringBuilder.Append(num.ToString(StringUtility.Contact("f", _decimal > _length ? _length : _decimal)));
            }
            return m_StringBuilder.ToString();
        }
    }
}