using System.Collections.Generic; using System.Collections; using cfg.GfgCfg; using ET; // using System; using UnityEngine; namespace GFGGame { public class StoryBonusDataCache { private static Dictionary _bonusDic = new Dictionary(); public static List GetBonusList(int levelID, bool hasOnce, bool showRandom = false) { StoryBonusData bonusData = GetBonusData(levelID); List bonusList = new List(); if (hasOnce) { bonusList.AddRange(bonusData.bonusOnce); } if (bonusData.bonusBase != null) { bonusList.AddRange(bonusData.bonusBase); } if (showRandom) { if (bonusData.bonusRandom != null && bonusData.bonusRandom.Count > 0) { bonusList.AddRange(bonusData.bonusRandom); } } return bonusList; } public static List GetBaseBonusList(int levelID) { StoryBonusData bonusData = GetBonusData(levelID); if (bonusData.bonusBase != null) { return bonusData.bonusBase; } return null; } public static List GetChapterBonusList(int chapterID, int index) { StoryChapterCfg chapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterID); List bonus = chapterCfg.Bonus1.ToGfgGameItemParam(); if (index == 1) { bonus = chapterCfg.Bonus2.ToGfgGameItemParam(); } else if (index == 2) { bonus = chapterCfg.Bonus3.ToGfgGameItemParam(); } return ItemUtil.CreateItemDataList(bonus); } public static int GetChapterBonusStar(int chapterID, int index) { StoryChapterCfg chapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterID); int star = chapterCfg.BonusStar1; if (index == 1) { star = chapterCfg.BonusStar2; } else if (index == 2) { star = chapterCfg.BonusStar3; } return star; } public static StoryBonusData GetBonusData(int levelID) { StoryBonusData bonusData = null; if (!_bonusDic.ContainsKey(levelID)) { bonusData = new StoryBonusData(); _bonusDic.Add(levelID, bonusData); StoryLevelCfg levelCfg = CommonDataManager.Tables.TblStoryLevelCfg.GetOrDefault(levelID); bonusData.bonusOnce = ItemUtil.CreateItemDataList(levelCfg.BonusOnce.ToGfgGameItemParam(), true); if (levelCfg.FightID != null && levelCfg.FightID.Length > 0) { StoryFightCfg fightCfg = CommonDataManager.Tables.TblStoryFightCfg.GetOrDefault(int.Parse(levelCfg.FightID)); bonusData.bonusBase = ItemUtil.CreateItemDataList(fightCfg.BonusBase.ToGfgGameItemParam()); bonusData.bonusRandom = DropOutDataCache.GetDropItemDatas(fightCfg.BonusRandom, false); } } else { bonusData = _bonusDic[levelID]; } return bonusData; } } }