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 _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 GetCurrentShowList() { return _showList.GetRange(0, _showList.Count); } // public static List GetBonusList(int count, bool isGuide = false) // { // List 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 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 GetBonusDataList(int[] idsList) { List list = new List(); 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; } } }