|
@@ -1,7 +1,5 @@
|
|
|
using System;
|
|
|
-using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
-using UnityEngine;
|
|
|
|
|
|
namespace GFGGame
|
|
|
{
|
|
@@ -71,24 +69,101 @@ namespace GFGGame
|
|
|
LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
|
|
|
if (!_dicShowList.ContainsKey(boxId))
|
|
|
{
|
|
|
- _dicShowList[boxId] = GetBonusDataList(luckyBoxCfg.bonusShowArr);
|
|
|
+ _dicShowList[boxId] = InitBonusDataList(luckyBoxCfg.dropId);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
- private List<LuckyBoxBonusData> GetBonusDataList(int[] idsList)
|
|
|
+
|
|
|
+ private List<LuckyBoxBonusData> InitBonusDataList(int dropId)
|
|
|
{
|
|
|
+ Dictionary<int, LuckyBoxBonusData> dic = new Dictionary<int, LuckyBoxBonusData>();
|
|
|
+ AddToBonusDataDic(dropId, dic);
|
|
|
List<LuckyBoxBonusData> list = new List<LuckyBoxBonusData>();
|
|
|
- foreach (int id in idsList)
|
|
|
+ foreach(var t in dic)
|
|
|
{
|
|
|
- BonusListCfg bonusListCfg = BonusListCfgArray.Instance.GetCfg(id);
|
|
|
- LuckyBoxBonusData luckyBoxBonusData = new LuckyBoxBonusData();
|
|
|
- luckyBoxBonusData.id = id;
|
|
|
- luckyBoxBonusData.name = bonusListCfg.name;
|
|
|
- luckyBoxBonusData.itemList = ItemUtil.CreateItemDataList(bonusListCfg.bonusListArr);
|
|
|
- list.Add(luckyBoxBonusData);
|
|
|
+ list.Add(t.Value);
|
|
|
}
|
|
|
+ list.Sort(CompareBonusData);
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ private void AddToBonusDataDic(int dropId, Dictionary<int, LuckyBoxBonusData> dic)
|
|
|
+ {
|
|
|
+ List<DropOutCfg> cfgs = DropOutCfgArray.Instance.GetCfgsByid(dropId);
|
|
|
+ if (cfgs == null)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ foreach (DropOutCfg cfg in cfgs)
|
|
|
+ {
|
|
|
+ if (cfg.item > ConstItemID.MAX_ITEM_ID)//掉落id
|
|
|
+ {
|
|
|
+ AddToBonusDataDic(cfg.item, dic);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ var group = cfg.group;
|
|
|
+ if (cfg.group <= 0)
|
|
|
+ {
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(cfg.item);
|
|
|
+ if (itemCfg == null || itemCfg.suitId <= 0)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ group = itemCfg.suitId;
|
|
|
+ }
|
|
|
+ LuckyBoxBonusData luckyBoxBonusData = GetBonusData(group, dic);
|
|
|
+ if (luckyBoxBonusData == null)
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ luckyBoxBonusData.itemList.Add(ItemUtil.createItemData(cfg.item, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private LuckyBoxBonusData GetBonusData(int group, Dictionary<int, LuckyBoxBonusData> dic)
|
|
|
+ {
|
|
|
+ dic.TryGetValue(group, out LuckyBoxBonusData luckyBoxBonusData);
|
|
|
+ if(luckyBoxBonusData != null)
|
|
|
+ {
|
|
|
+ return luckyBoxBonusData;
|
|
|
+ }
|
|
|
+ luckyBoxBonusData = new LuckyBoxBonusData();
|
|
|
+ luckyBoxBonusData.id = group;
|
|
|
+ BonusListCfg bonusListCfg = BonusListCfgArray.Instance.GetCfg(group);
|
|
|
+ if (bonusListCfg != null)
|
|
|
+ {
|
|
|
+ luckyBoxBonusData.name = bonusListCfg.name;
|
|
|
+ luckyBoxBonusData.order = bonusListCfg.sort;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(group);
|
|
|
+ if (suitCfg == null)
|
|
|
+ {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ luckyBoxBonusData.name = suitCfg.name;
|
|
|
+ luckyBoxBonusData.order = 9999;
|
|
|
+ }
|
|
|
+ dic.Add(group, luckyBoxBonusData);
|
|
|
+ return luckyBoxBonusData;
|
|
|
+ }
|
|
|
+
|
|
|
+ public int CompareBonusData(LuckyBoxBonusData a, LuckyBoxBonusData b)
|
|
|
+ {
|
|
|
+ if(b.order < a.order)
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ if(b.order > a.order)
|
|
|
+ {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ return a.id - b.id;
|
|
|
+ }
|
|
|
+
|
|
|
public void GetOwnedCount(int boxId, out int count, out int totalCount)
|
|
|
{
|
|
|
count = 0;
|