| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System.Collections.Generic;
- using System.Collections;
- using cfg.GfgCfg;
- // using System;
- using UnityEngine;
- namespace GFGGame
- {
- public class StoryBonusDataCache
- {
- private static Dictionary<int, StoryBonusData> _bonusDic = new Dictionary<int, StoryBonusData>();
- public static List<ItemData> GetBonusList(int levelID, bool hasOnce, bool showRandom = false)
- {
- StoryBonusData bonusData = GetBonusData(levelID);
- List<ItemData> bonusList = new List<ItemData>();
- 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<ItemData> GetBaseBonusList(int levelID)
- {
- StoryBonusData bonusData = GetBonusData(levelID);
- if (bonusData.bonusBase != null)
- {
- return bonusData.bonusBase;
- }
- return null;
- }
- public static List<ItemData> GetChapterBonusList(int chapterID, int index)
- {
- StoryChapterCfg chapterCfg = CommonDataManager.Tables.TblStoryChapterCfg.GetOrDefault(chapterID);
- List<ItemParam> 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;
- }
- }
- }
|