提交 | 用户 | age
|
d56e0c
|
1 |
using System.Collections;
|
H |
2 |
using System.Collections.Generic;
|
|
3 |
using UnityEngine;
|
|
4 |
using System;
|
|
5 |
|
4465b6
|
6 |
namespace vnxbqy.UI
|
d56e0c
|
7 |
{
|
H |
8 |
|
|
9 |
public class EquipStarModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize
|
|
10 |
{
|
|
11 |
public readonly LogicInt selectedLevel = new LogicInt();
|
|
12 |
public readonly LogicInt selectedPlace = new LogicInt();
|
|
13 |
public readonly LogicInt equipStarLevel = new LogicInt();
|
|
14 |
public readonly LogicInt equipMaxStarLevel = new LogicInt();
|
|
15 |
public readonly LogicList<EquipStarUpgradeCandidate> candidatePlaces = new LogicList<EquipStarUpgradeCandidate>();
|
|
16 |
|
|
17 |
public readonly LogicList<Star> stars = new LogicList<Star>();
|
|
18 |
|
|
19 |
public readonly LogicInt specialMaterial = new LogicInt();
|
|
20 |
public readonly LogicInt specialMaterial2 = new LogicInt();
|
|
21 |
public readonly LogicInt starResultEffect = new LogicInt();
|
|
22 |
public readonly LogicInt autoBuy = new LogicInt();
|
|
23 |
public Int2 jumpEquipPos = Int2.zero;
|
|
24 |
public List<string> useStarMaterials = new List<string>(); //可用于升星的装备
|
|
25 |
public string biggestRateMaterial = string.Empty; //低境界非红装的最高概率一件
|
|
26 |
|
|
27 |
Dictionary<int, EquipSetStar> equipStars = new Dictionary<int, EquipSetStar>();
|
|
28 |
public Dictionary<int, EquipSetStar> EquipStars { get { return equipStars; } }
|
|
29 |
|
|
30 |
Redpoint redpoint = new Redpoint(106, 1720000);
|
|
31 |
bool redpointDirty = false;
|
|
32 |
LogicUpdate logicUpdate = new LogicUpdate(1);
|
|
33 |
|
|
34 |
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
35 |
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
36 |
|
|
37 |
|
|
38 |
public static List<int> StarList = new List<int> { 0, 3, 6, 9, 12, 15, 18 };
|
|
39 |
|
|
40 |
public override void Init()
|
|
41 |
{
|
|
42 |
ParseConfig();
|
|
43 |
|
|
44 |
logicUpdate.Start(OnUpdate);
|
|
45 |
packModel.refreshItemCountEvent += OnItemCountRefresh;
|
|
46 |
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent += OnGetUpgradeStarResult;
|
|
47 |
|
|
48 |
autoBuy.value = -1;
|
|
49 |
}
|
|
50 |
|
|
51 |
public override void UnInit()
|
|
52 |
{
|
|
53 |
packModel.refreshItemCountEvent -= OnItemCountRefresh;
|
|
54 |
DTC0721_tagMakeItemAnswer.MakeItemAnswerEvent -= OnGetUpgradeStarResult;
|
|
55 |
}
|
|
56 |
|
|
57 |
public void OnBeforePlayerDataInitialize()
|
|
58 |
{
|
|
59 |
foreach (var equipStar in equipStars)
|
|
60 |
{
|
|
61 |
equipStar.Value.ResetStarLevel();
|
|
62 |
}
|
|
63 |
}
|
|
64 |
|
|
65 |
public void OnPlayerLoginOk()
|
|
66 |
{
|
|
67 |
}
|
|
68 |
|
|
69 |
public void UpdateStarLevels(HA3B1_tagMCEquipPartStarInfo info)
|
|
70 |
{
|
|
71 |
var selectedEquipOldStar = GetEquipStarLevel(new Int2(selectedLevel.value, selectedPlace.value));
|
|
72 |
for (var i = 0; i < info.InfoList.Length; i++)
|
|
73 |
{
|
|
74 |
var equipPosition = EquipSet.ServerPlaceToClientPlace(info.InfoList[i].EquipPackIndex);
|
|
75 |
var level = equipPosition.x;
|
|
76 |
if (equipStars.ContainsKey(level))
|
|
77 |
{
|
|
78 |
equipStars[level].UpdateEquipStarLevel(equipPosition.y, info.InfoList[i].Star);
|
|
79 |
}
|
|
80 |
}
|
|
81 |
|
|
82 |
var starLevel = GetEquipStarLevel(new Int2(selectedLevel.value, selectedPlace.value));
|
|
83 |
equipStarLevel.value = starLevel;
|
|
84 |
selectedPlace.dirty = true;
|
|
85 |
|
|
86 |
var maxStarLevel = GetMaxStarLevel(selectedLevel.value);
|
|
87 |
UpdateSelelctedEquipStars(selectedEquipOldStar, starLevel, maxStarLevel);
|
|
88 |
|
|
89 |
for (int i = 0; i < candidatePlaces.Count; i++)
|
|
90 |
{
|
|
91 |
var candidate = candidatePlaces[i];
|
|
92 |
candidate.starLevel.value = GetEquipStarLevel(candidate.equipPosition);
|
|
93 |
}
|
|
94 |
|
|
95 |
redpointDirty = true;
|
|
96 |
}
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
void OnGetUpgradeStarResult(H0721_tagMakeItemAnswer info)
|
|
101 |
{
|
|
102 |
if (info.MakeType == (byte)MakeType.EquipStarUpgrade)
|
|
103 |
{
|
|
104 |
var equipPosition = new Int2(selectedLevel.value, selectedPlace.value);
|
|
105 |
AutoAddMaterials(equipPosition);
|
|
106 |
|
|
107 |
if (info.Result == 1)
|
|
108 |
{
|
|
109 |
var successModel = ModelCenter.Instance.GetModel<EquipStarSuccessModel>();
|
|
110 |
successModel.Show(equipPosition, GetStarLevel(equipPosition));
|
|
111 |
starResultEffect.value = 1;
|
|
112 |
|
|
113 |
}
|
|
114 |
else
|
|
115 |
{
|
|
116 |
EffectMgr.Instance.PlayUIEffect(7066, 2500, WindowCenter.Instance.uiRoot.tipsCanvas, false);
|
|
117 |
SysNotifyMgr.Instance.ShowTip("StarLevelUpFail");
|
|
118 |
starResultEffect.value = -1;
|
|
119 |
}
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
//装备已填充100%后,客户端自己计算升星石价格
|
|
125 |
public int GetItemsMoney(Int2 equipPosition, int starLevel)
|
|
126 |
{
|
|
127 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, starLevel);
|
|
128 |
if (config == null)
|
|
129 |
{
|
|
130 |
return 0;
|
|
131 |
}
|
|
132 |
int itemID = config.CostItemDict[0].x;
|
|
133 |
int count = config.CostItemDict[0].y;
|
|
134 |
if (itemID <= 0 || count <= 0) return 0;
|
|
135 |
var shopConfig = StoreConfig.GetStoreCfg(itemID, 2, 5);
|
|
136 |
if (shopConfig == null) return 0;
|
|
137 |
|
|
138 |
int hasCnt = packModel.GetItemCountByID(PackType.Item, config.CostItemDict[0].x);
|
|
139 |
int needCnt = count >= hasCnt ? count - hasCnt : 0;
|
|
140 |
return needCnt * shopConfig.MoneyNumber;
|
|
141 |
}
|
|
142 |
|
f7e1f1
|
143 |
|
d56e0c
|
144 |
public void DoStarUpgrade(Int2 equipPosition, int starLevel, int auto=0)
|
H |
145 |
{
|
|
146 |
if (!equipStars.ContainsKey(equipPosition.x))
|
|
147 |
{
|
|
148 |
return;
|
|
149 |
}
|
|
150 |
|
|
151 |
var equip = packModel.GetItemByGuid(equipModel.GetEquip(equipPosition));
|
|
152 |
if (equip == null)
|
|
153 |
{
|
|
154 |
return;
|
|
155 |
}
|
|
156 |
|
|
157 |
if (equip.config.ItemColor < 4)
|
|
158 |
{
|
|
159 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp4");
|
|
160 |
return;
|
|
161 |
}
|
|
162 |
|
|
163 |
var maxLevel = GetMaxStarLevel(equipPosition.x);
|
|
164 |
if (starLevel > maxLevel)
|
|
165 |
{
|
|
166 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp1");
|
|
167 |
return;
|
|
168 |
}
|
|
169 |
|
|
170 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, starLevel);
|
|
171 |
if (config == null)
|
|
172 |
{
|
|
173 |
return;
|
|
174 |
}
|
|
175 |
|
|
176 |
if (config.CostItemDict[0].x > 0 && specialMaterial.value == 0 && auto == 0)
|
|
177 |
{
|
|
178 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp2", config.CostItemDict[0].x);
|
3aa853
|
179 |
ItemTipUtility.Show(config.CostItemDict[0].x);
|
d56e0c
|
180 |
return;
|
H |
181 |
}
|
|
182 |
|
|
183 |
if (config.CostItemDict.Length > 1 && config.CostItemDict[1].x > 0 && specialMaterial2.value == 0 )
|
|
184 |
{
|
|
185 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp2", config.CostItemDict[1].x);
|
3aa853
|
186 |
ItemTipUtility.Show(config.CostItemDict[1].x);
|
d56e0c
|
187 |
return;
|
H |
188 |
}
|
|
189 |
|
|
190 |
if (config.CostItemDict[0].x > 0 && packModel.GetItemCountByID(PackType.Item, config.CostItemDict[0].x) < config.CostItemDict[0].y && auto == 0)
|
|
191 |
{
|
|
192 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp2", config.CostItemDict[0].x);
|
3aa853
|
193 |
ItemTipUtility.Show(config.CostItemDict[0].x);
|
d56e0c
|
194 |
return;
|
H |
195 |
}
|
2d44df
|
196 |
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(2, config.CostItemDict[0].x, config.CostItemDict[0].y, 1, 0);
|
L |
197 |
LimitedTimeLuxuryGiftModel.Instance.IsItemIdShow(2, config.CostItemDict[1].x, config.CostItemDict[1].y, 1, 0);
|
d56e0c
|
198 |
if (config.CostItemDict.Length > 1 && config.CostItemDict[1].x > 0 &&
|
H |
199 |
packModel.GetItemCountByID(PackType.Item, config.CostItemDict[1].x) < config.CostItemDict[1].y)
|
|
200 |
{
|
|
201 |
SysNotifyMgr.Instance.ShowTip("StarLevelUp2", config.CostItemDict[1].x);
|
3aa853
|
202 |
ItemTipUtility.Show(config.CostItemDict[1].x);
|
d56e0c
|
203 |
return;
|
H |
204 |
}
|
|
205 |
|
|
206 |
var materialIndexs = new List<ushort>();
|
|
207 |
var materialItemIds = new List<uint>();
|
|
208 |
|
|
209 |
|
|
210 |
Action sendInfo = () =>
|
|
211 |
{
|
|
212 |
var info = new CA5C5_tagCMEquipPartStarUp();
|
|
213 |
info.EquipPackIndex = (ushort)EquipSet.ClientPlaceToServerPlace(equipPosition);
|
|
214 |
info.CostEquipIndex = materialIndexs.ToArray();
|
|
215 |
info.CostEquipID = materialItemIds.ToArray();
|
|
216 |
info.CostEquipCnt = (byte)materialIndexs.Count;
|
|
217 |
info.AutoBuy = (byte)auto;
|
|
218 |
GameNetSystem.Instance.SendInfo(info);
|
|
219 |
};
|
|
220 |
|
|
221 |
sendInfo();
|
|
222 |
}
|
|
223 |
|
|
224 |
public void ResetOperateParams()
|
|
225 |
{
|
|
226 |
if (autoBuy.value == -2) autoBuy.value = -1;
|
|
227 |
selectedLevel.value = 0;
|
|
228 |
selectedPlace.value = 0;
|
|
229 |
equipStarLevel.value = 0;
|
|
230 |
equipMaxStarLevel.value = 0;
|
|
231 |
starResultEffect.value = 0;
|
|
232 |
stars.Clear();
|
|
233 |
}
|
|
234 |
|
|
235 |
public Int2 GetRecommendEquipPosition()
|
|
236 |
{
|
|
237 |
foreach (var starSet in equipStars.Values)
|
|
238 |
{
|
|
239 |
var level = starSet.level;
|
|
240 |
for (var place = 1; place <= 12; place++)
|
|
241 |
{
|
|
242 |
var isRedpoint = starSet.GetRedpointState(place) != RedPointState.None;
|
|
243 |
if (isRedpoint)
|
|
244 |
{
|
|
245 |
return new Int2(level, place);
|
|
246 |
}
|
|
247 |
}
|
|
248 |
}
|
|
249 |
|
|
250 |
foreach (var starSet in equipStars.Values)
|
|
251 |
{
|
|
252 |
var level = starSet.level;
|
|
253 |
for (var i = 1; i <= 12; i++)
|
|
254 |
{
|
|
255 |
var equipPosition = new Int2(level, i);
|
|
256 |
var item = packModel.GetItemByGuid(equipModel.GetEquip(equipPosition));
|
|
257 |
if (item == null)
|
|
258 |
{
|
|
259 |
continue;
|
|
260 |
}
|
|
261 |
|
|
262 |
var starLevel = GetStarLevel(equipPosition);
|
|
263 |
var maxStarLevel = GetMaxStarLevel(item.config.ItemColor, item.config.LV);
|
|
264 |
if (starLevel >= maxStarLevel)
|
|
265 |
{
|
|
266 |
continue;
|
|
267 |
}
|
|
268 |
}
|
|
269 |
}
|
|
270 |
|
|
271 |
return new Int2(1, 1);
|
|
272 |
}
|
|
273 |
|
|
274 |
public void SelectLevel(int level)
|
|
275 |
{
|
|
276 |
selectedLevel.value = level;
|
|
277 |
candidatePlaces.Clear();
|
|
278 |
|
|
279 |
if (level > 0)
|
|
280 |
{
|
|
281 |
// int equipCnt = level < 2 ? 8 : 12;
|
|
282 |
for (var i = 1; i <= 12; i++)
|
|
283 |
{
|
|
284 |
var place = i;
|
|
285 |
var equipPosition = new Int2(level, place);
|
|
286 |
var candidate = new EquipStarUpgradeCandidate(equipPosition);
|
|
287 |
candidate.starLevel.value = GetEquipStarLevel(equipPosition);
|
|
288 |
candidatePlaces.Add(candidate);
|
|
289 |
}
|
|
290 |
candidatePlaces.Sort(EquipStarUpgradeCandidateCompare);
|
|
291 |
|
|
292 |
SelectPlace(candidatePlaces[0].equipPosition);
|
|
293 |
}
|
|
294 |
else
|
|
295 |
{
|
|
296 |
SelectPlace(Int2.zero);
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
public void SelectPlace(Int2 equipPosition)
|
|
301 |
{
|
|
302 |
selectedPlace.value = equipPosition.y;
|
|
303 |
selectedPlace.dirty = true;
|
|
304 |
if (equipPosition.x > 0 && equipPosition.y >= 1 && equipPosition.y <= 12)
|
|
305 |
{
|
|
306 |
for (int i = 0; i < candidatePlaces.Count; i++)
|
|
307 |
{
|
|
308 |
var candidate = candidatePlaces[i];
|
|
309 |
candidate.selected.value = candidate.equipPosition == equipPosition;
|
|
310 |
}
|
|
311 |
|
|
312 |
var starLevel = GetEquipStarLevel(equipPosition);
|
|
313 |
var maxStarLevel = GetMaxStarLevel(equipPosition.x);
|
|
314 |
equipStarLevel.value = starLevel;
|
|
315 |
equipMaxStarLevel.value = maxStarLevel;
|
|
316 |
|
|
317 |
UpdateSelelctedEquipStars(starLevel, starLevel, maxStarLevel);
|
|
318 |
AutoAddMaterials(equipPosition);
|
|
319 |
}
|
|
320 |
}
|
|
321 |
|
|
322 |
//是否可升星
|
|
323 |
public bool IsEquipPlaceUpgradable(string equipGuid)
|
|
324 |
{
|
|
325 |
if (string.IsNullOrEmpty(equipGuid))
|
|
326 |
{
|
|
327 |
return false;
|
|
328 |
}
|
|
329 |
|
|
330 |
var equip = packModel.GetItemByGuid(equipGuid);
|
|
331 |
if (equip == null)
|
|
332 |
{
|
|
333 |
return false;
|
|
334 |
}
|
|
335 |
|
|
336 |
var maxStarLevel = GetMaxStarLevel(equip.config.ItemColor, equip.config.LV);
|
|
337 |
var currentStarLevel = GetEquipStarLevel(new Int2(equip.config.LV, equip.config.EquipPlace));
|
|
338 |
return currentStarLevel < maxStarLevel;
|
|
339 |
}
|
|
340 |
|
|
341 |
public static int GetMaxStarLevel(int quality, int level)
|
|
342 |
{
|
|
343 |
var max = 0;
|
|
344 |
if (GeneralDefine.equipStarLimit.ContainsKey(quality))
|
|
345 |
{
|
|
346 |
var itemLevelStars = GeneralDefine.equipStarLimit[quality];
|
|
347 |
if (itemLevelStars.ContainsKey(level))
|
|
348 |
{
|
|
349 |
max = itemLevelStars[level];
|
|
350 |
}
|
|
351 |
}
|
|
352 |
|
|
353 |
return max;
|
|
354 |
}
|
|
355 |
|
|
356 |
public static int GetMaxStarLevel(int level)
|
|
357 |
{
|
|
358 |
var max = 0;
|
|
359 |
foreach (var itemLevelStars in GeneralDefine.equipStarLimit.Values)
|
|
360 |
{
|
|
361 |
if (itemLevelStars.ContainsKey(level))
|
|
362 |
{
|
|
363 |
if (itemLevelStars[level] > max)
|
|
364 |
{
|
|
365 |
max = itemLevelStars[level];
|
|
366 |
}
|
|
367 |
}
|
|
368 |
}
|
|
369 |
|
|
370 |
return max;
|
|
371 |
}
|
|
372 |
|
|
373 |
public int GetEquipPositionMaxStarLevel(Int2 equipPosition)
|
|
374 |
{
|
|
375 |
var equipGuid = equipModel.GetEquip(equipPosition);
|
|
376 |
if (equipGuid == null)
|
|
377 |
{
|
|
378 |
return 0;
|
|
379 |
}
|
|
380 |
|
|
381 |
var equip = packModel.GetItemByGuid(equipGuid);
|
|
382 |
if (equip == null)
|
|
383 |
{
|
|
384 |
return 0;
|
|
385 |
}
|
|
386 |
|
|
387 |
return GetMaxStarLevel(equip.config.ItemColor, equip.config.LV);
|
|
388 |
}
|
|
389 |
|
|
390 |
public int GetTotalStarLevel(int level)
|
|
391 |
{
|
|
392 |
if (!equipStars.ContainsKey(level))
|
|
393 |
{
|
|
394 |
return 0;
|
|
395 |
}
|
|
396 |
|
|
397 |
return equipStars[level].GetTotalStarLevel();
|
|
398 |
}
|
|
399 |
|
|
400 |
/// <summary>
|
|
401 |
/// 这是指已经装备位置已经升级到的星级,不考虑当前穿戴的装备
|
|
402 |
/// </summary>
|
|
403 |
/// <param name="equipPosition"></param>
|
|
404 |
/// <returns></returns>
|
|
405 |
public int GetStarLevel(Int2 equipPosition)
|
|
406 |
{
|
|
407 |
if (!equipStars.ContainsKey(equipPosition.x))
|
|
408 |
{
|
|
409 |
return 0;
|
|
410 |
}
|
|
411 |
|
|
412 |
return equipStars[equipPosition.x].GetEquipStarLevel(equipPosition.y);
|
|
413 |
}
|
|
414 |
|
|
415 |
/// <summary>
|
|
416 |
/// 这是指受当前装备限制的星级,比如当前装备位已经升级到了9星,但是穿戴的装备最高可升级到6星,那么返回的值是6
|
|
417 |
/// </summary>
|
|
418 |
/// <param name="equipPosition"></param>
|
|
419 |
/// <returns></returns>
|
|
420 |
public int GetEquipStarLevel(Int2 equipPosition)
|
|
421 |
{
|
|
422 |
var starLevel = GetStarLevel(equipPosition);
|
|
423 |
var maxLevel = GetEquipPositionMaxStarLevel(equipPosition);
|
|
424 |
|
|
425 |
return Mathf.Min(starLevel, maxLevel);
|
|
426 |
}
|
|
427 |
|
|
428 |
public List<int> GetMaterialGetWays(Int2 equipPosition, int starLevel)
|
|
429 |
{
|
|
430 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, starLevel);
|
|
431 |
if (config == null)
|
|
432 |
{
|
|
433 |
return null;
|
|
434 |
}
|
|
435 |
|
|
436 |
var getWays = new List<int>();
|
|
437 |
foreach (int place in config.CostEquipPlace)
|
|
438 |
{
|
|
439 |
var equipControlConfig = EquipControlConfig.Get(equipPosition.x, place);
|
|
440 |
foreach (int getWay in equipControlConfig.getWays)
|
|
441 |
{
|
|
442 |
if (!getWays.Contains(getWay))
|
|
443 |
{
|
|
444 |
getWays.Add(getWay);
|
|
445 |
}
|
|
446 |
}
|
|
447 |
}
|
|
448 |
|
|
449 |
return getWays;
|
|
450 |
}
|
|
451 |
|
|
452 |
//1、可提升战力装备不显示.
|
|
453 |
//2、红装排最后
|
|
454 |
//3、境界,小于等级自身的优先显示
|
|
455 |
//4、特殊处理概率【最高】的一件低境界非红装显示在第一件
|
|
456 |
|
|
457 |
//筛选可用于升星的装备材料
|
|
458 |
public List<string> GetMaterials(Int2 equipPosition, int starLevel)
|
|
459 |
{
|
|
460 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, starLevel);
|
|
461 |
if (config == null)
|
|
462 |
{
|
|
463 |
return null;
|
|
464 |
}
|
|
465 |
|
|
466 |
var equipGuid = equipModel.GetEquip(equipPosition);
|
|
467 |
var equip = packModel.GetItemByGuid(equipGuid);
|
|
468 |
if (equip == null)
|
|
469 |
{
|
|
470 |
return null;
|
|
471 |
}
|
|
472 |
|
|
473 |
var expcetMaterials = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
|
|
474 |
{
|
|
475 |
qualitys = new List<int>(config.CostEquipColor),
|
|
476 |
equipTypes = new List<int>(config.CostEquipPlace),
|
|
477 |
jobs = config.IsJobLimit == 1 ? new List<int>() { PlayerDatas.Instance.baseData.Job } : null,
|
|
478 |
});
|
|
479 |
|
|
480 |
float rate = 0;
|
|
481 |
var materialGuids = new List<string>();
|
|
482 |
foreach (var item in expcetMaterials)
|
|
483 |
{
|
|
484 |
if (ItemLogicUtility.Instance.IsFightUpEx(item.itemId, item.score, item.config.RealmLimit) == -1)
|
|
485 |
{
|
|
486 |
//4、特殊处理概率【最高】的一件低境界非红装显示在第一件
|
|
487 |
if (item.config.ItemColor <= 4 && item.config.RealmLimit <= PlayerDatas.Instance.baseData.realmLevel)
|
|
488 |
{
|
|
489 |
var tmpRate = GetMaterialSuccessRate(equipPosition, item.guid);
|
|
490 |
if (rate < tmpRate)
|
|
491 |
{
|
|
492 |
biggestRateMaterial = item.guid;
|
|
493 |
rate = tmpRate;
|
|
494 |
}
|
|
495 |
}
|
|
496 |
|
|
497 |
//不显示更高战力的装备
|
|
498 |
materialGuids.Add(item.guid);
|
|
499 |
}
|
|
500 |
}
|
|
501 |
|
|
502 |
materialGuids.Remove(biggestRateMaterial);
|
|
503 |
return materialGuids;
|
|
504 |
}
|
|
505 |
|
|
506 |
|
|
507 |
private void AutoAddMaterials(Int2 equipPosition)
|
|
508 |
{
|
|
509 |
var equipGuid = equipModel.GetEquip(equipPosition);
|
|
510 |
var upgradable = IsEquipPlaceUpgradable(equipGuid);
|
|
511 |
|
|
512 |
if (upgradable)
|
|
513 |
{
|
|
514 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, GetEquipStarLevel(equipPosition) + 1);
|
|
515 |
if (config.CostItemDict.Length > 0 && config.CostItemDict[0].x > 0)
|
|
516 |
{
|
|
517 |
var itemId = config.CostItemDict[0].x;
|
|
518 |
specialMaterial.value = itemId;
|
|
519 |
}
|
|
520 |
else
|
|
521 |
{
|
|
522 |
specialMaterial.value = 0;
|
|
523 |
}
|
|
524 |
if (config.CostItemDict.Length > 1)
|
|
525 |
{
|
|
526 |
var itemId = config.CostItemDict[1].x;
|
|
527 |
specialMaterial2.value = itemId;
|
|
528 |
}
|
|
529 |
else
|
|
530 |
{
|
|
531 |
specialMaterial2.value = 0;
|
|
532 |
}
|
|
533 |
}
|
|
534 |
|
|
535 |
}
|
|
536 |
|
|
537 |
|
|
538 |
|
|
539 |
public float GetMaterialSuccessRate(Int2 equipPosition, string guid)
|
|
540 |
{
|
|
541 |
if (string.IsNullOrEmpty(guid))
|
|
542 |
{
|
|
543 |
return 0f;
|
|
544 |
}
|
|
545 |
|
|
546 |
var item = packModel.GetItemByGuid(guid);
|
|
547 |
if (item == null)
|
|
548 |
{
|
|
549 |
return 0f;
|
|
550 |
}
|
|
551 |
|
|
552 |
var currentStarLevel = GetEquipStarLevel(equipPosition);
|
|
553 |
var config = EquipStarConfig.Get(equipPosition.x, equipPosition.y, currentStarLevel + 1);
|
|
554 |
if (config == null)
|
|
555 |
{
|
|
556 |
return 0f;
|
|
557 |
}
|
|
558 |
|
|
559 |
var amendLevel = item.config.LV - equipPosition.x;
|
|
560 |
var amendRate = 1f;
|
|
561 |
if (amendLevel > 0)
|
|
562 |
{
|
|
563 |
amendRate = 1 + amendLevel * GeneralDefine.equipStarUpAmendFactor * 0.01f;
|
|
564 |
}
|
|
565 |
else
|
|
566 |
{
|
|
567 |
amendRate = 1 + amendLevel * GeneralDefine.equipStarDownAmendFactor * 0.01f;
|
|
568 |
}
|
|
569 |
|
|
570 |
var successRate = 0.5f;
|
|
571 |
var isSuit = item.config.SuiteiD > 0;
|
|
572 |
if (isSuit)
|
|
573 |
{
|
|
574 |
successRate = Mathf.Clamp(Mathf.CeilToInt((float)Math.Round(config.SuitRate * amendRate, 2)), GeneralDefine.suitEquipStarUpgradeRateFloor, GeneralDefine.suitEquipStarUpgradeRateCeiling);
|
|
575 |
}
|
|
576 |
else
|
|
577 |
{
|
|
578 |
successRate = Mathf.Clamp(Mathf.CeilToInt((float)Math.Round(config.UnSuitRate * amendRate, 2)), GeneralDefine.normalEquipStarUpgradeRateFloor, GeneralDefine.normalEquipStarUpgradeRateCeiling);
|
|
579 |
}
|
|
580 |
|
|
581 |
return successRate * 0.01f;
|
|
582 |
}
|
|
583 |
|
|
584 |
private void UpdateSelelctedEquipStars(int oldStarLevel, int newStarLevel, int maxStarLevel)
|
|
585 |
{
|
|
586 |
stars.Clear();
|
|
587 |
for (var i = 1; i <= maxStarLevel; i++)
|
|
588 |
{
|
|
589 |
stars.Add(new Star()
|
|
590 |
{
|
|
591 |
actived = i <= newStarLevel,
|
|
592 |
newGet = i <= newStarLevel && i > oldStarLevel,
|
|
593 |
});
|
|
594 |
}
|
|
595 |
}
|
|
596 |
|
|
597 |
private void OnItemCountRefresh(PackType type, int index, int itemId)
|
|
598 |
{
|
|
599 |
switch (type)
|
|
600 |
{
|
|
601 |
case PackType.Item:
|
573c7f
|
602 |
//if (ItemLogicUtility.Instance.IsRealmEquip(itemId))
|
H |
603 |
//{
|
|
604 |
// redpointDirty = true;
|
|
605 |
//}
|
d56e0c
|
606 |
|
H |
607 |
var itemConfig = ItemConfig.Get(itemId);
|
|
608 |
if (itemConfig.Type == 34)
|
|
609 |
{
|
|
610 |
redpointDirty = true;
|
|
611 |
}
|
573c7f
|
612 |
else if (itemId == 633)
|
H |
613 |
{
|
|
614 |
redpointDirty = true;
|
|
615 |
}
|
|
616 |
|
d56e0c
|
617 |
break;
|
H |
618 |
case PackType.Equip:
|
|
619 |
var clientEquipPosition = EquipSet.ServerPlaceToClientPlace(index);
|
|
620 |
if (clientEquipPosition.x > 0)
|
|
621 |
{
|
|
622 |
redpointDirty = true;
|
|
623 |
}
|
|
624 |
break;
|
|
625 |
}
|
|
626 |
}
|
724c6d
|
627 |
|
d56e0c
|
628 |
private void UpdateStarRedpoint()
|
H |
629 |
{
|
|
630 |
var targetEquipPosition = Int2.zero;
|
|
631 |
var minStarLevel = 999;
|
|
632 |
foreach (var trainSet in equipStars.Values)
|
|
633 |
{
|
|
634 |
var level = trainSet.level;
|
|
635 |
for (var place = 1; place <= 12; place++)
|
|
636 |
{
|
|
637 |
var equipPosition = new Int2(level, place);
|
|
638 |
var item = packModel.GetItemByGuid(equipModel.GetEquip(equipPosition));
|
|
639 |
if (item == null)
|
|
640 |
{
|
|
641 |
continue;
|
|
642 |
}
|
|
643 |
|
|
644 |
//达到最大星级
|
|
645 |
var maxStarLevel = GetMaxStarLevel(item.config.ItemColor, item.config.LV);
|
|
646 |
var starLevel = GetStarLevel(new Int2(level, place));
|
|
647 |
if (starLevel >= maxStarLevel)
|
|
648 |
{
|
|
649 |
continue;
|
|
650 |
}
|
|
651 |
|
|
652 |
//不是候选者中星级最小的
|
|
653 |
if (targetEquipPosition != Int2.zero && starLevel >= minStarLevel)
|
|
654 |
{
|
|
655 |
continue;
|
|
656 |
}
|
|
657 |
|
|
658 |
var config = EquipStarConfig.Get(level, place, starLevel + 1);
|
|
659 |
if (config == null)
|
|
660 |
{
|
|
661 |
continue;
|
|
662 |
}
|
|
663 |
|
|
664 |
//固定材料不足
|
|
665 |
if (config.CostItemDict[0].x > 0 && packModel.GetItemCountByID(PackType.Item, config.CostItemDict[0].x) < config.CostItemDict[0].y)
|
|
666 |
{
|
|
667 |
continue;
|
|
668 |
}
|
|
669 |
|
|
670 |
if (config.CostItemDict.Length > 1 && config.CostItemDict[1].x > 0 &&
|
|
671 |
packModel.GetItemCountByID(PackType.Item, config.CostItemDict[1].x) < config.CostItemDict[1].y)
|
|
672 |
{
|
|
673 |
continue;
|
|
674 |
}
|
|
675 |
|
573c7f
|
676 |
//var materials = packModel.GetItems(PackType.Item, new SinglePack.FilterParams()
|
H |
677 |
//{
|
|
678 |
// qualitys = new List<int>(config.CostEquipColor),
|
|
679 |
// equipTypes = new List<int>(config.CostEquipPlace),
|
|
680 |
// levels = new List<int>() { item.config.LV },
|
|
681 |
// jobs = config.IsJobLimit == 1 ? new List<int>() { PlayerDatas.Instance.baseData.Job } : null,
|
|
682 |
//});
|
d56e0c
|
683 |
|
573c7f
|
684 |
//for (int j = materials.Count - 1; j >= 0; j--)
|
H |
685 |
//{
|
|
686 |
// var material = materials[j];
|
|
687 |
// if (ItemLogicUtility.Instance.IsFightUp(material.itemId, material.score) == 1)
|
|
688 |
// {
|
|
689 |
// materials.RemoveAt(j);
|
|
690 |
// }
|
|
691 |
//}
|
d56e0c
|
692 |
|
573c7f
|
693 |
//var successRate = 0f;
|
H |
694 |
//foreach (var material in materials)
|
|
695 |
//{
|
|
696 |
// successRate += GetMaterialSuccessRate(equipPosition, material.guid);
|
|
697 |
// if (successRate >= 0.5f)
|
|
698 |
// {
|
|
699 |
// break;
|
|
700 |
// }
|
|
701 |
//}
|
d56e0c
|
702 |
|
573c7f
|
703 |
//if (successRate < 0.5f)
|
H |
704 |
//{
|
|
705 |
// continue;
|
|
706 |
//}
|
d56e0c
|
707 |
|
H |
708 |
minStarLevel = starLevel;
|
|
709 |
targetEquipPosition = new Int2(level, place);
|
|
710 |
}
|
|
711 |
}
|
|
712 |
|
|
713 |
foreach (var starSet in equipStars.Values)
|
|
714 |
{
|
|
715 |
var level = starSet.level;
|
|
716 |
if (!equipModel.IsLevelUnLocked(level))
|
|
717 |
{
|
|
718 |
continue;
|
|
719 |
}
|
|
720 |
|
|
721 |
for (var place = 1; place <= 12; place++)
|
|
722 |
{
|
|
723 |
var isRedpoint = level == targetEquipPosition.x && place == targetEquipPosition.y;
|
|
724 |
starSet.UpdateRedpoint(place, isRedpoint ? RedPointState.Simple : RedPointState.None);
|
|
725 |
}
|
|
726 |
}
|
|
727 |
}
|
|
728 |
|
|
729 |
private void OnUpdate()
|
|
730 |
{
|
|
731 |
if (redpointDirty && FuncOpen.Instance.IsFuncOpen(172))
|
|
732 |
{
|
|
733 |
redpointDirty = false;
|
|
734 |
UpdateStarRedpoint();
|
|
735 |
}
|
|
736 |
}
|
|
737 |
|
|
738 |
private int EquipStarUpgradeCandidateCompare(EquipStarUpgradeCandidate x, EquipStarUpgradeCandidate y)
|
|
739 |
{
|
|
740 |
var guidX = equipModel.GetEquip(x.equipPosition);
|
|
741 |
var guidY = equipModel.GetEquip(y.equipPosition);
|
|
742 |
if (!string.IsNullOrEmpty(guidX) && string.IsNullOrEmpty(guidY))
|
|
743 |
{
|
|
744 |
return -1;
|
|
745 |
}
|
|
746 |
|
|
747 |
if (string.IsNullOrEmpty(guidX) && !string.IsNullOrEmpty(guidY))
|
|
748 |
{
|
|
749 |
return 1;
|
|
750 |
}
|
|
751 |
return x.equipPosition.y.CompareTo(y.equipPosition.y);
|
|
752 |
|
|
753 |
//var factorX = x.equipPosition.x * 100 + x.equipPosition.y;
|
|
754 |
//var factorY = y.equipPosition.x * 100 + y.equipPosition.y;
|
|
755 |
|
|
756 |
//if (string.IsNullOrEmpty(guidX) && string.IsNullOrEmpty(guidY))
|
|
757 |
//{
|
|
758 |
// return factorX.CompareTo(factorY);
|
|
759 |
//}
|
|
760 |
|
|
761 |
//var equipX = packModel.GetItemByGuid(guidX);
|
|
762 |
//var equipY = packModel.GetItemByGuid(guidY);
|
|
763 |
|
|
764 |
//var canUpgradeStarLevelX = GetMaxStarLevel(equipX.config.ItemColor, equipX.config.LV) - GetStarLevel(x.equipPosition);
|
|
765 |
//var canUpgradeStarLevelY = GetMaxStarLevel(equipY.config.ItemColor, equipY.config.LV) - GetStarLevel(y.equipPosition);
|
|
766 |
|
|
767 |
//var compareResult = canUpgradeStarLevelX.CompareTo(canUpgradeStarLevelY);
|
|
768 |
//if (compareResult != 0)
|
|
769 |
//{
|
|
770 |
// return -compareResult;
|
|
771 |
//}
|
|
772 |
|
|
773 |
//return factorX.CompareTo(factorY);
|
|
774 |
}
|
|
775 |
|
|
776 |
private void ParseConfig()
|
|
777 |
{
|
|
778 |
var configs = EquipStarConfig.GetValues();
|
|
779 |
foreach (var config in configs)
|
|
780 |
{
|
|
781 |
if (!equipStars.ContainsKey(config.Level))
|
|
782 |
{
|
|
783 |
equipStars[config.Level] = new EquipSetStar(config.Level);
|
|
784 |
}
|
|
785 |
}
|
|
786 |
}
|
|
787 |
|
|
788 |
public struct Star
|
|
789 |
{
|
|
790 |
public bool actived;
|
|
791 |
public bool newGet;
|
|
792 |
}
|
|
793 |
|
|
794 |
}
|
|
795 |
}
|
|
796 |
|