123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- using System.Collections.Generic;
- using UnityEngine;
- using System;
- namespace GFGGame
- {
- public class LuckyBoxBonusDataCache
- {
- private static int _currentBoxId;
- private static int _currentSelectId;
- public static int currentBoxId
- {
- get
- {
- return _currentBoxId;
- }
- set
- {
- if (_currentBoxId != value)
- {
- _currentBoxId = value;
- InitData(_currentBoxId);
- }
- }
- }
- public static string probShow;
- private static List<LuckyBoxBonusData> _showList;
- // private static int _dropOutId;
- // private static int _dropId;
- public static int GetOwnedCount()
- {
- int count = 0;
- foreach (LuckyBoxBonusData luckyBoxBonusData in _showList)
- {
- foreach (ItemData itemData in luckyBoxBonusData.itemList)
- {
- if (ItemDataManager.GetItemNum(itemData.id) > 0)
- {
- count++;
- }
- }
- }
- return count;
- }
- public static List<LuckyBoxBonusData> GetCurrentShowList()
- {
- return _showList.GetRange(0, _showList.Count);
- }
- // public static List<ItemData> GetBonusList(int count, bool isGuide = false)
- // {
- // List<ItemData> bonusList = null;
- // if (isGuide)
- // {
- // int[][] temp = new int[5][];
- // temp[0] = new int[] { 10332, 1 };
- // temp[1] = new int[] { 10334, 1 };
- // temp[2] = new int[] { 10335, 1 };
- // temp[3] = new int[] { 10336, 1 };
- // temp[4] = new int[] { 10338, 1 };
- // List<ItemData> guideBonusList = ItemUtil.CreateItemDataList(temp);
- // count = count - guideBonusList.Count;
- // bonusList = DropOutDataCache.GetDropItemDatas(_dropOutId, count);
- // while (guideBonusList.Count > 1)
- // {
- // ItemData itemData = guideBonusList[0];
- // guideBonusList.RemoveAt(0);
- // int index = UnityEngine.Random.Range(0, bonusList.Count);
- // bonusList.Insert(index, itemData);
- // }
- // bonusList.Add(guideBonusList[0]);
- // }
- // else
- // {
- // bonusList = DropOutDataCache.GetDropItemDatas(_dropOutId, count);
- // }
- // int dicIndex = 0;
- // LuckyBoxDataManager.Instance.FirstRewardList.Clear();
- // foreach (ItemData itemData in bonusList)
- // {
- // if (ItemDataManager.GetItemNum(itemData.id) == 0)
- // {
- // LuckyBoxDataManager.Instance.FirstRewardList.Add(dicIndex, itemData);
- // }
- // ItemDataManager.Add(itemData.id, itemData.num);
- // dicIndex++;
- // }
- // ItemDataManager.Add(_dropId, count);
- // //100¸öÐÇм»»1¸öÂäÐÇʯ
- // LuckyBoxCfg boxCfg0 = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxIds[0]);
- // LuckyBoxCfg boxCfg1 = LuckyBoxCfgArray.Instance.GetCfg(LuckyBoxDataManager.Instance.luckyBoxIds[1]);
- // int itemCount = ItemDataManager.GetItemNum(boxCfg0.drop);
- // if (_dropId == boxCfg0.drop && itemCount >= 100)
- // {
- // ItemDataManager.Add(boxCfg1.drop, itemCount / 100);
- // ItemDataManager.Remove(_dropId, itemCount / 100 * 100);
- // }
- // GetSuitItemController.TryShow(0);
- // return bonusList;
- // }
- private static void InitData(int boxId)
- {
- LuckyBoxCfg luckyBoxCfg = LuckyBoxCfgArray.Instance.GetCfg(boxId);
- probShow = luckyBoxCfg.probShow;
- _showList = GetBonusDataList(luckyBoxCfg.bonusShowArr);
- // _dropOutId = luckyBoxCfg.bonus;
- // _dropId = luckyBoxCfg.drop;
- }
- private static List<LuckyBoxBonusData> GetBonusDataList(int[] idsList)
- {
- List<LuckyBoxBonusData> list = new List<LuckyBoxBonusData>();
- foreach (int id in idsList)
- {
- 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);
- }
- return list;
- }
- }
- }
|