12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System.Collections.Generic;
- using System.Collections;
- // 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 doRandom = false)
- {
- StoryBonusData bonusData = GetBonusData(levelID);
- List<ItemData> bonusList = new List<ItemData>();
- 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);
- if (fightCfg != null)
- {
- List<ItemData> randomList = DropOutDataCache.GetDropItemDatas1(fightCfg.bonusRandomArr, true);
- bonusList.AddRange(randomList);
- }
- }
- else
- {
- bonusList.AddRange(bonusData.bonusRandom);
- }
- }
- }
- if (bonusData.bonusBase != null)
- {
- bonusList.AddRange(bonusData.bonusBase);
- }
- 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 = 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(int 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.GetDropItemDatas1(fightCfg.bonusRandomArr, false);
- }
- }
- else
- {
- bonusData = _bonusDic[levelID];
- }
- return bonusData;
- }
- }
- }
|