//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Sunday, February 04, 2018
|
//--------------------------------------------------------
|
|
using System.Collections.Generic;
|
|
public partial class ChestsAwardConfig : IConfigPostProcess
|
{
|
|
private static Dictionary<string, ChestsAwardConfig> chestAwardDict = new Dictionary<string, ChestsAwardConfig>();
|
private static Dictionary<int, List<int>> chestIdDict = new Dictionary<int, List<int>>();
|
public 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;
|
}
|
|
public static bool IsBox(int itemID)
|
{
|
return chestIdDict.ContainsKey(itemID);
|
}
|
}
|