zhaoyang 3 жил өмнө
parent
commit
9ff7bd07a6

+ 101 - 101
GameClient/Assets/Game/HotUpdate/Data/Cache/DropOutDataCache.cs

@@ -8,116 +8,31 @@ namespace GFGGame
         private static Dictionary<int, List<DropOutData>> _probDic = new Dictionary<int, List<DropOutData>>();
 
 
+        // public static List<ItemData> GetDropItemDatas(int[] dropIds, bool doRandome)
+        // {
+        //     List<ItemData> result = new List<ItemData>();
+        //     foreach (int dropId in dropIds)
+        //     {
+        //         ItemData itemData = GetDropItemData(dropId, doRandome);
+        //         if (itemData != null)
+        //         {
+        //             result.Add(itemData);
+        //         }
+        //     }
+        //     return result;
+        // }
         public static List<ItemData> GetDropItemDatas(int[] dropIds, bool doRandome)
         {
             List<ItemData> result = new List<ItemData>();
             foreach (int dropId in dropIds)
             {
-                ItemData itemData = GetDropItemData(dropId, doRandome);
-                if (itemData != null)
-                {
-                    result.Add(itemData);
-                }
-            }
-            return result;
-        }
+                GetDropItemData(dropId, result);
 
-        public static List<ItemData> GetDropItemDatas(int dropId, int count)
-        {
-            List<ItemData> result = new List<ItemData>();
-            int tryCount = 0;
-            while (result.Count < count && tryCount < 1000)
-            {
-                ItemData itemData = GetDropItemData(dropId, true);
-                if (itemData != null)
-                {
-                    result.Add(itemData);
-                }
-                tryCount++;
             }
             return result;
         }
 
-        public static ItemData GetDropItemData(int dropId, bool doRandome)
-        {
-            ItemData itemData = null;
-            List<DropOutData> dropOutDatas = null;
-            if (!_probDic.ContainsKey(dropId))
-            {
-                InitData(dropId);
-            }
-            dropOutDatas = _probDic[dropId];
-            if (dropOutDatas != null)
-            {
-                float result = Random.Range(0, 1f);
-                foreach (DropOutData dropOutData in dropOutDatas)
-                {
-                    if (result <= dropOutData.WeightEnd || !doRandome)
-                    {
-                        return GetItemData(dropOutData.dropOutCfg, doRandome);
-                    }
-                }
-            }
-            return itemData;
-        }
-
-        private static void InitData(int dropId)
-        {
-            List<DropOutData> dropOutDatas = new List<DropOutData>();
-            _probDic[dropId] = dropOutDatas;
-            var arr = DropOutCfgArray.Instance.GetCfgs(dropId);
-            List<DropOutCfg> cfgs = new List<DropOutCfg>(arr);
-            float totalWeight = 0;
-            foreach (DropOutCfg cfg in cfgs)
-            {
-                totalWeight += cfg.weight;
-            }
-            float weightEnd = 0;
-            foreach (DropOutCfg cfg in cfgs)
-            {
-                DropOutData dropOutData = new DropOutData();
-                dropOutData.dropOutCfg = cfg;
-                weightEnd += cfg.weight;
-                dropOutData.WeightEnd = weightEnd / totalWeight;
-                dropOutDatas.Add(dropOutData);
-            }
-        }
-
-        private static ItemData GetItemData(DropOutCfg dropOutCfg, bool doRandomeNum)
-        {
-            if (dropOutCfg.item >= 10000000)//掉落id
-            {
-                return GetDropItemData(dropOutCfg.item, doRandomeNum);
-            }
-            else if (dropOutCfg.item > 0)
-            {
-                int num = dropOutCfg.maxNum;
-                if (doRandomeNum)
-                {
-                    num = Random.Range(dropOutCfg.minNum, dropOutCfg.maxNum + 1);
-                }
-                if (num > 0)
-                {
-                    ItemData itemData = ItemDataPool.GetItemData(dropOutCfg.item);
-                    itemData.num = num;
-                    return itemData;
-                }
-            }
-            return null;
-        }
-
-        public static List<ItemData> GetDropItemDatas1(int[] dropIds, bool doRandome)
-        {
-            List<ItemData> result = new List<ItemData>();
-            foreach (int dropId in dropIds)
-            {
-                GetDropItemDatas(dropId, result);
-
-            }
-            return result;
-        }
-
-        public static List<ItemData> GetDropItemDatas(int dropId, List<ItemData> result)
+        public static List<ItemData> GetDropItemData(int dropId, List<ItemData> result)
         {
 
             List<DropOutCfg> dropOutCfgs = DropOutCfgArray.Instance.GetCfgs(dropId);
@@ -129,7 +44,7 @@ namespace GFGGame
                 if (_dropOutCfgs.Count > 0)
                 {
 
-                    GetDropItemDatas(dropOutCfgs[i].item, result);
+                    GetDropItemData(dropOutCfgs[i].item, result);
                 }
                 else
                 {
@@ -142,5 +57,90 @@ namespace GFGGame
             }
             return result;
         }
+        // public static List<ItemData> GetDropItemDatas(int dropId, int count)
+        // {
+        //     List<ItemData> result = new List<ItemData>();
+        //     int tryCount = 0;
+        //     while (result.Count < count && tryCount < 1000)
+        //     {
+        //         ItemData itemData = GetDropItemData(dropId, true);
+        //         if (itemData != null)
+        //         {
+        //             result.Add(itemData);
+        //         }
+        //         tryCount++;
+        //     }
+        //     return result;
+        // }
+
+        // public static ItemData GetDropItemData(int dropId, bool doRandome)
+        // {
+        //     ItemData itemData = null;
+        //     List<DropOutData> dropOutDatas = null;
+        //     if (!_probDic.ContainsKey(dropId))
+        //     {
+        //         InitData(dropId);
+        //     }
+        //     dropOutDatas = _probDic[dropId];
+        //     if (dropOutDatas != null)
+        //     {
+        //         float result = Random.Range(0, 1f);
+        //         foreach (DropOutData dropOutData in dropOutDatas)
+        //         {
+        //             if (result <= dropOutData.WeightEnd || !doRandome)
+        //             {
+        //                 return GetItemData(dropOutData.dropOutCfg, doRandome);
+        //             }
+        //         }
+        //     }
+        //     return itemData;
+        // }
+
+        // private static void InitData(int dropId)
+        // {
+        //     List<DropOutData> dropOutDatas = new List<DropOutData>();
+        //     _probDic[dropId] = dropOutDatas;
+        //     var arr = DropOutCfgArray.Instance.GetCfgs(dropId);
+        //     List<DropOutCfg> cfgs = new List<DropOutCfg>(arr);
+        //     float totalWeight = 0;
+        //     foreach (DropOutCfg cfg in cfgs)
+        //     {
+        //         totalWeight += cfg.weight;
+        //     }
+        //     float weightEnd = 0;
+        //     foreach (DropOutCfg cfg in cfgs)
+        //     {
+        //         DropOutData dropOutData = new DropOutData();
+        //         dropOutData.dropOutCfg = cfg;
+        //         weightEnd += cfg.weight;
+        //         dropOutData.WeightEnd = weightEnd / totalWeight;
+        //         dropOutDatas.Add(dropOutData);
+        //     }
+        // }
+
+        // private static ItemData GetItemData(DropOutCfg dropOutCfg, bool doRandomeNum)
+        // {
+        //     if (dropOutCfg.item >= 10000000)//掉落id
+        //     {
+        //         return GetDropItemData(dropOutCfg.item, doRandomeNum);
+        //     }
+        //     else if (dropOutCfg.item > 0)
+        //     {
+        //         int num = dropOutCfg.maxNum;
+        //         if (doRandomeNum)
+        //         {
+        //             num = Random.Range(dropOutCfg.minNum, dropOutCfg.maxNum + 1);
+        //         }
+        //         if (num > 0)
+        //         {
+        //             ItemData itemData = ItemDataPool.GetItemData(dropOutCfg.item);
+        //             itemData.num = num;
+        //             return itemData;
+        //         }
+        //     }
+        //     return null;
+        // }
+
+
     }
 }

+ 11 - 20
GameClient/Assets/Game/HotUpdate/Data/Cache/StoryBonusDataCache.cs

@@ -8,38 +8,29 @@ namespace GFGGame
     {
         private static Dictionary<int, StoryBonusData> _bonusDic = new Dictionary<int, StoryBonusData>();
 
-        public static List<ItemData> GetBonusList(int levelID, bool hasOnce, bool doRandom = false)
+        public static List<ItemData> GetBonusList(int levelID, bool hasOnce)
         {
             StoryBonusData bonusData = GetBonusData(levelID);
             List<ItemData> bonusList = new List<ItemData>();
             if (hasOnce)
             {
                 bonusList.AddRange(bonusData.bonusOnce);
+                if (bonusData.bonusBase != null)
+                {
+                    bonusList.AddRange(bonusData.bonusBase);
+                }
             }
             else
             {
+                if (bonusData.bonusBase != null)
+                {
+                    bonusList.AddRange(bonusData.bonusBase);
+                }
                 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);
-                    }
+                    bonusList.AddRange(bonusData.bonusRandom);
                 }
             }
-            if (bonusData.bonusBase != null)
-            {
-                bonusList.AddRange(bonusData.bonusBase);
-            }
 
             return bonusList;
         }
@@ -83,7 +74,7 @@ namespace GFGGame
                 {
                     StoryFightCfg fightCfg = StoryFightCfgArray.Instance.GetCfg(levelCfg.fightID);
                     bonusData.bonusBase = ItemUtil.CreateItemDataList(fightCfg.bonusBaseArr);
-                    bonusData.bonusRandom = DropOutDataCache.GetDropItemDatas1(fightCfg.bonusRandomArr, false);
+                    bonusData.bonusRandom = DropOutDataCache.GetDropItemDatas(fightCfg.bonusRandomArr, false);
                 }
             }
             else

+ 1 - 1
GameClient/Assets/Game/HotUpdate/ServerProxy/InstanceZonesSProxy.cs

@@ -36,7 +36,7 @@ namespace GFGGame
             {
                 if (response.Error == ErrorCode.ERR_Success)
                 {
-                    List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true, true);
+                    List<ItemData> bonusList = StoryBonusDataCache.GetBonusList(response.LevelCfgId, true);
                     InstanceZonesDataManager.TrySetLevelPass(response.LevelCfgId);
                     InstanceZonesController.OnFinishStoryLevel(levelCfgId, true, true);
                     FunctionOpenDataManager.Instance.CheckHasChapterFunOpen(response.LevelCfgId);//首次通过要检查是否有功能开启