| using System.Collections.Generic;  | 
|   | 
| public partial class ChestsAwardConfig : ConfigBase<int, ChestsAwardConfig>  | 
| {  | 
|   | 
|     private static Dictionary<string, ChestsAwardConfig> chestAwardDict = new Dictionary<string, ChestsAwardConfig>();  | 
|     private static Dictionary<int, List<int>> chestIdDict = new Dictionary<int, List<int>>();  | 
|       | 
|     protected override void OnConfigParseCompleted()  | 
|     {  | 
|         string key = StringUtility.Contact(BoxID, BoxLV);  | 
|         if (!chestAwardDict.ContainsKey(key))  | 
|         {  | 
|             chestAwardDict.Add(key, this);  | 
|         }  | 
|   | 
|         if (!chestIdDict.ContainsKey(BoxID))  | 
|         {  | 
|             List<int> boxLvlist = new List<int>();  | 
|             boxLvlist.Add(BoxLV);  | 
|             chestIdDict.Add(BoxID, boxLvlist);  | 
|         }  | 
|         else  | 
|         {  | 
|             chestIdDict[BoxID].Add(BoxLV);  | 
|         }  | 
|     }  | 
|   | 
|     public static ChestsAwardConfig GetChestsAwardByID(int boxId)  | 
|     {  | 
|         int playerLv = PlayerDatas.Instance.baseData.LV;  | 
|         List<int> boxLvlist = null;  | 
|         int boxLv = 0;  | 
|         chestIdDict.TryGetValue(boxId, out boxLvlist);  | 
|         if (boxLvlist != null)  | 
|         {  | 
|             boxLvlist.Sort();  | 
|             for (int i = boxLvlist.Count - 1; i > -1; i--)  | 
|             {  | 
|                 if (boxLvlist[i] <= playerLv)  | 
|                 {  | 
|                     boxLv = boxLvlist[i];  | 
|                     break;  | 
|                 }  | 
|             }  | 
|         }  | 
|         return GetChestsAwardByIDAndLv(boxId, boxLv);  | 
|     }  | 
|   | 
|     private static ChestsAwardConfig GetChestsAwardByIDAndLv(int id, int lv)  | 
|     {  | 
|         ChestsAwardConfig chestsAwardConfig = null;  | 
|         string key = StringUtility.Contact(id, lv);  | 
|         chestAwardDict.TryGetValue(key, out chestsAwardConfig);  | 
|         return chestsAwardConfig;  | 
|     }  | 
|   | 
|     //0:不是箱子,1:随机箱子 2:自选箱子  | 
|     public static int GetBoxType(int itemID)  | 
|     {  | 
|         if (!chestIdDict.ContainsKey(itemID))  | 
|         {  | 
|             return 0;  | 
|         }  | 
|         var config = GetChestsAwardByID(itemID);  | 
|         return string.IsNullOrEmpty(config.SelectList) ? 1 : 2;  | 
|     }  | 
| }  | 
|   | 
|   | 
|   | 
|   | 
|   |