少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, March 14, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
 
    public class EquipEvolutionWin : Window
    {
        // 强化大师界面
        [SerializeField] Button m_EvolutionBtn;
        [SerializeField] Text m_BtnText;
        [SerializeField] Button m_CloseButton;
        [SerializeField] RectTransform m_equipList;
        [SerializeField] ScrollerController m_MasterAttrCtrl;
        [SerializeField] RawImage m_RawRole;
        [SerializeField] Text m_NewEeffectTip;
 
        #region Built-in
        EquipStrengthModel strengthModel { get { return ModelCenter.Instance.GetModel<EquipStrengthModel>(); } }
        PackModel playerPack { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
 
        int activeMasterPlusLV = 0;
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseButton.AddListener(() => { CloseImmediately(); });
            m_EvolutionBtn.AddListener(OnClickEvolutionBtn);
        }
 
        bool isNewEffect = false;
 
        protected override void OnPreOpen()
        {
            m_MasterAttrCtrl.OnRefreshCell += OnRefreshCell;
            strengthModel.StrengthMasterFresh += Show;
            //Text addText = m_AttributesText1.transform.Find("Number").GetComponent<Text>();
            isNewEffect = false;
            Show();
            
        }
        
 
        protected override void OnAfterOpen()
        {
            
        }
 
        protected override void OnPreClose()
        {
            m_MasterAttrCtrl.OnRefreshCell -= OnRefreshCell;
            strengthModel.StrengthMasterFresh -= Show;
        }
 
 
 
        protected override void OnAfterClose()
        {
            UI3DModelExhibition.Instance.StopShow();
        }
        #endregion
 
 
        private void OnClickEvolutionBtn()
        {
            if (activeMasterPlusLV > 0)
                SendActiveMaster();
            else
                CloseImmediately();
        }
 
        void DisplayPlayer()
        {
            m_NewEeffectTip.SetActive(isNewEffect);
            m_RawRole.SetActive(true);
 
            var appearance = equipModel.GetAppearance(strengthModel.SelectLevel);
            UI3DModelExhibition.Instance.ShowPlayer(m_RawRole, new UI3DPlayerExhibitionData()
            {
                job = PlayerDatas.Instance.baseData.Job,
                clothesId = appearance.clothes,
                weaponId = appearance.weapon,
                secondaryId = appearance.secondary,
                keepRotation = false,
                reikiRootEffectId = strengthModel.GetMasterLV(strengthModel.SelectLevel),
                suitLevel = appearance.isSuit ? 1 : 0,
                equipLevel = strengthModel.SelectLevel,
            });
 
            isNewEffect = true;
        }
        private void Show()
        {
            var masterInfo = ItemPlusMasterConfig.TryGetNextMaster(strengthModel.SelectLevel, strengthModel.GetMasterLV(strengthModel.SelectLevel));
            int masterPlusLV = (masterInfo != null) ? masterInfo.MasterPlusLV : 0;
            
            for (int i = 1; i <= 8; i++)
            {
                var plusLV = strengthModel.GetStrengthLevelByColor(strengthModel.SelectLevel, i);
                //m_equipList
                Text plusLvText = m_equipList.transform.Find("Img_Icon" + i).Find("Text").GetComponent<Text>();
                plusLvText.text = UIHelper.AppendColor(plusLV >= masterPlusLV ? TextColType.DarkGreen:TextColType.Gray, "+" + plusLV, true);
                Image light = m_equipList.transform.Find("Img_Icon" + i).Find("Img_Icon").GetComponent<Image>();
                light.SetActive(plusLV >= masterPlusLV ? true: false);
            }
            CreateScroll();
            RefreshButton();
 
            DisplayPlayer();
        }
 
        private void CreateScroll()
        {
            int i = 0;
            m_MasterAttrCtrl.Refresh();
            var curMasterLV = strengthModel.GetMasterLV(strengthModel.SelectLevel);
            int jumpIndex = -1;
            foreach (var items in ItemPlusMasterConfig.GetMasters(strengthModel.SelectLevel))
            {
                CellInfo info = new CellInfo();
                info.infoInt1 = items.Key;
                m_MasterAttrCtrl.AddCell(ScrollerDataType.Header, i, info);
                if (jumpIndex == -1 && curMasterLV < items.Key)
                {
                    jumpIndex = Math.Max(i - 2, 0);
                }
                i++;
            }
            m_MasterAttrCtrl.Restart();
            m_MasterAttrCtrl.JumpIndex(jumpIndex);
        }
            
        private void OnRefreshCell(ScrollerDataType type, CellView cell)
        {
            if (type == ScrollerDataType.Header)
            {
                var masterCell = cell as EquipStrengthMasterCell;
                int plusLV = masterCell.info.Value.infoInt1;
                masterCell.ShowMasterAttr(strengthModel.SelectLevel, plusLV);
            }
 
        }
 
        private void RefreshButton()
        {
            //activeMasterPlusLV
 
            var curMasterLV = strengthModel.GetMasterLV(strengthModel.SelectLevel);
            var masterInfo = ItemPlusMasterConfig.TryGetNextMaster(strengthModel.SelectLevel, curMasterLV);
 
            bool canBright = false;
            if (masterInfo != null && (strengthModel.GetStrengthMinLV(strengthModel.SelectLevel) >= masterInfo.MasterPlusLV))
                canBright = true;
 
            if (canBright)
                activeMasterPlusLV = masterInfo.MasterPlusLV;
            else
                activeMasterPlusLV = 0;
            m_BtnText.text = canBright ? Language.Get("Z2004"): Language.Get("RuneTowerSweepText12");
        }
 
        public void SendActiveMaster()
        {
            CA5C7_tagCMActivateMasterPlusLV CA5C7 = new CA5C7_tagCMActivateMasterPlusLV();
            CA5C7.ClassLV = (byte)strengthModel.SelectLevel;
            CA5C7.MasterPlusLV = (ushort)activeMasterPlusLV;
 
            GameNetSystem.Instance.SendInfo(CA5C7);
        }
    }
    
 
}