using System.Collections.Generic; using System.Collections; // using System; using UnityEngine; namespace GFGGame { public class StoryBonusDataCache { private static Dictionary _bonusDic = new Dictionary(); public static List GetBonusList(string levelID, bool hasOnce, bool doRandom = false) { StoryBonusData bonusData = GetBonusData(levelID); List bonusList = new List(); if (hasOnce) { bonusList.AddRange(bonusData.bonusOnce); } else { if (bonusData.bonusRandom != null && bonusData.bonusRandom.Count > 0) { if (doRandom) { StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelID); StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); List randomList = DropOutDataCache.GetDropItemDatas(fightCfg.bonusRandomArr, true); bonusList.AddRange(randomList); } else { bonusList.AddRange(bonusData.bonusRandom); } } } if (bonusData.bonusBase != null) { bonusList.AddRange(bonusData.bonusBase); } return bonusList; } public static List GetChapterBonusList(int chapterID, int index) { StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(chapterID); int[][] bonus = chapterCfg.bonus1Arr; if (index == 1) { bonus = chapterCfg.bonus2Arr; } else if (index == 2) { bonus = chapterCfg.bonus3Arr; } return ItemUtil.CreateItemDataList(bonus); } public static StoryBonusData GetBonusData(string levelID) { StoryBonusData bonusData = null; if (!_bonusDic.ContainsKey(levelID)) { bonusData = new StoryBonusData(); _bonusDic.Add(levelID, bonusData); StoryLevelCfg levelCfg = StoryLevelCfgArray.Instance.GetCfg(levelID); bonusData.bonusOnce = ItemUtil.CreateItemDataList(levelCfg.bonusOnceArr, true); if (levelCfg.fightID != null && levelCfg.fightID.Length > 0) { StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID); bonusData.bonusBase = ItemUtil.CreateItemDataList(fightCfg.bonusBaseArr); bonusData.bonusRandom = DropOutDataCache.GetDropItemDatas(fightCfg.bonusRandomArr, false); } } else { bonusData = _bonusDic[levelID]; } return bonusData; } } }