少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//--------------------------------------------------------
//    [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);
    }
}