| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 | 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 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 = 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 int GetChapterBonusStar(int chapterID, int index)        {            StoryChapterCfg chapterCfg = StoryChapterCfgArray.Instance.GetCfg(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 = 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;        }    }}
 |