少年修仙传客户端代码仓库
client_Wu Xijin
2019-02-20 a87120c155c48fa45b20a97c1a58bdbeb77318b7
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
using System;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using System.Collections;
 
namespace Snxxz.UI
{
    public class WashMasterActiveWin : Window
    {
        [SerializeField] Image titleImg;
        [SerializeField] UIAlphaTween titleAlphaTween;
        [SerializeField] ScaleTween titleScaleTween;
        [SerializeField] PositionTween leftPosTween;
        [SerializeField] UIEffect leftEffect;
        [SerializeField] WindowInfo windowInfo;
 
        [Header("武器洗练大师")]
        [SerializeField] GameObject weaponObj;
        [Header("防具洗练大师")]
        [SerializeField] GameObject defenceObj;
        [Header("仙器洗练大师")]
        [SerializeField] GameObject fairyObj;
 
        [Header("洗练大师激活")]
        [SerializeField] Transform activeParent;
        [SerializeField] GameObject activeAttrObj;
        [SerializeField] Text fightNumText;
        [SerializeField] GameObject activeAttrCell;
        [SerializeField] CalculateLayout activeLayout;
        [Header("洗练大师升阶")]
        [SerializeField] Transform raiseParent;
        [SerializeField] GameObject raiseLvAttrObj;
        [SerializeField] Text preLvText;
        [SerializeField] Text curLvText;
        [SerializeField] GameObject raiseAttrCell;
        [SerializeField] CalculateLayout raiseLayout;
 
        private List<EquipWashSpecConfig.EquipWashSpecData> washSpeclist = null;
        List<GameObject> tempCelllist = new List<GameObject>();
        EquipWashModel equipWashModel { get{ return  ModelCenter.Instance.GetModel<EquipWashModel>();}}
 
        Dictionary<int, int> curAttrDict = new Dictionary<int, int>();
        Dictionary<int, int> preAttrDict = new Dictionary<int, int>();
        int curFightNum = 0;
        int preFightNum = 0;
 
        protected override void BindController()
        {
 
        }
        protected override void AddListeners()
        {
            
        }
 
        protected override void OnPreOpen()
        {
            curFightNum = 0;
            preFightNum = 0;
            washSpeclist = null;
            tempCelllist.Clear();
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            SetTitleUI();
        }
        protected override void OnAfterOpen()
        {
            StartCoroutine(CloseRayTarget());
        }
 
        protected override void OnPreClose()
        {
            for(int i = 0; i < tempCelllist.Count; i++)
            {
                DestroyObject(tempCelllist[i]);
            }
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        IEnumerator CloseRayTarget()
        {
            yield return null;
            windowInfo.raycastTarget = false;
        }
 
        private void SetTitleUI()
        {
            activeAttrObj.SetActive(false);
            raiseLvAttrObj.SetActive(false);
            leftPosTween.gameObject.SetActive(false);
            if (equipWashModel.MasterWashState == 1)
            {
                titleImg.SetSprite("UI_JH_10");
            }
            else if (equipWashModel.MasterWashState == 2)
            {
                titleImg.SetSprite("UI_JH_9");
            }
 
            titleAlphaTween.Play();
            titleScaleTween.Play(SetLeftUI);
        }
 
        private void SetLeftUI()
        {
            GetEquipWashGroup();
            leftPosTween.gameObject.SetActive(true);
            leftEffect.Play();
            leftPosTween.Play(SetRightUI);
        }
        
        private void SetRightUI()
        {
            washSpeclist = EquipWashSpecConfig.GetWashSpecModel(equipWashModel.washType);
            curAttrDict.Clear();
            preAttrDict.Clear();
            for (int i = 0; i < washSpeclist.Count; i++)
            {
                var washSpecData = washSpeclist[i];
                if (washSpecData.specConfig.levelNeed == equipWashModel.washLv)
                {
                    int[] attrIds = washSpecData.activeIds;
                    int[] curAttrValues = washSpecData.activeValues;
                    for (int j = 0; j < attrIds.Length; j++)
                    {
                        curAttrDict.Add(attrIds[j], curAttrValues[j]);
                    }
                    curFightNum = UIHelper.GetFightPower(curAttrDict);
 
                    if (equipWashModel.MasterWashState == 1)
                    {
                        activeAttrObj.SetActive(true);
                        raiseLvAttrObj.SetActive(false);
                        fightNumText.text = curFightNum.ToString();
                        CreateActiveCell(washSpeclist[i]);
                    }
                    else if (equipWashModel.MasterWashState == 2)
                    {
                        activeAttrObj.SetActive(false);
                        raiseLvAttrObj.SetActive(true);
                        var preWashSpecData = washSpeclist[i - 1];
                        int[] preAttrValues = preWashSpecData.activeValues;
                        for (int j = 0; j < attrIds.Length; j++)
                        {
                            preAttrDict.Add(attrIds[j], preAttrValues[j]);
                        }
                        preFightNum = UIHelper.GetFightPower(preAttrDict);
                        preLvText.text = preWashSpecData.specConfig.MasterLV.ToString();
                        curLvText.text = washSpecData.specConfig.MasterLV.ToString();
                        CreateRaiseCell(preWashSpecData,washSpecData);
                    }
                    break;
                }
            }
 
           windowInfo.raycastTarget = true;
        }
 
        private void GetEquipWashGroup()
        {
            weaponObj.SetActive(false);
            defenceObj.SetActive(false);
            fairyObj.SetActive(false);
 
            switch (equipWashModel.washType)
            {
                case 1:
                    weaponObj.SetActive(true);
                    break;
                case 2:
                    defenceObj.SetActive(true);
                    break;
                case 3:
                    fairyObj.SetActive(true);
                    break;
                default:
                    DebugEx.LogError("不存在此洗练群组" + equipWashModel.washType);
                    break;
            }
        }
 
        private void CreateActiveCell(EquipWashSpecConfig.EquipWashSpecData specConfig)
        {
            int[] attrIds = specConfig.activeIds;
            int[] attrValues = specConfig.activeValues;
            activeAttrCell.SetActive(false);
            for (int i = 0; i < attrIds.Length; i++)
            {
                PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(attrIds[i]);
                GameObject activeGo = Instantiate(activeAttrCell);
                activeGo.SetActive(true);
                activeGo.transform.SetParent(activeParent);
                activeGo.transform.localScale = Vector3.one;
                ActiveAttrCell activeCell = activeGo.GetComponent<ActiveAttrCell>();
                activeCell.SetModel(attrIds[i], attrValues[i]);
                tempCelllist.Add(activeGo);
            }
            activeLayout.Init(tempCelllist,true);
        }
 
        private void CreateRaiseCell(EquipWashSpecConfig.EquipWashSpecData preSpecConfig, EquipWashSpecConfig.EquipWashSpecData curSpecConfig)
        {
            int[] preAttrIds = preSpecConfig.activeIds;
            int[] preAttrValues = preSpecConfig.activeValues;
            int[] curAttrIds = curSpecConfig.activeIds;
            int[] curAttrValues = curSpecConfig.activeValues;
            raiseAttrCell.SetActive(false);
 
            tempCelllist.Add(GetRaiseGo(Language.Get("L1056"),preFightNum.ToString(),(curFightNum-preFightNum).ToString()));
 
            for (int i = 0; i < preAttrIds.Length; i++)
            {
                PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(preAttrIds[i]);
                tempCelllist.Add(GetRaiseGo(propertyConfig.Name, GetProValueTypeStr(propertyConfig, preAttrValues[i]),GetProValueTypeStr(propertyConfig, curAttrValues[i]-preAttrValues[i])));
            }
            raiseLayout.Init(tempCelllist,true);
        }
 
        private GameObject GetRaiseGo(string nameStr,string preValue,string curValue)
        {
            GameObject raiseGo = Instantiate(raiseAttrCell);
            raiseGo.SetActive(true);
            raiseGo.transform.SetParent(raiseParent);
            raiseGo.transform.localScale = Vector3.one;
            RaiseAttrCell raisecell = raiseGo.GetComponent<RaiseAttrCell>();
            raisecell.SetModel(nameStr,preValue,curValue);
            return raiseGo;
        }
 
        public string GetProValueTypeStr(PlayerPropertyConfig playerproModel, int value)
        {
            string s = "";
            if (playerproModel.ISPercentage == 0)
            {
                s = value.ToString();
            }
            else if (playerproModel.ISPercentage == 1)
            {
                s = (float)Math.Round(value / 100f, 1) + "%";
            }
            else if (playerproModel.ISPercentage == 2)
            {
                s = ((float)Math.Round(value / 100f, 1)).ToString();
            }
            return s;
        }
    }
}