//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Sunday, February 04, 2018 //-------------------------------------------------------- using System.Collections.Generic; namespace TableConfig { public partial class ChestsAwardConfig : ConfigBase, IConfigPostProcess { private static Dictionary chestAwardDict = new Dictionary(); private static Dictionary> chestIdDict = new Dictionary>(); public void OnConfigParseCompleted() { string key = StringUtility.Contact(BoxID, BoxLV); if (!chestAwardDict.ContainsKey(key)) { chestAwardDict.Add(key, this); } if (!chestIdDict.ContainsKey(BoxID)) { List boxLvlist = new List(); 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 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; } } }