lcy
4 天以前 2dd1841d03a730d3d369092c2a3ad656cee4bf64
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
using System.Collections.Generic;
 
public partial class ActTotalRechargeTempConfig : ConfigBase<int, ActTotalRechargeTempConfig>
{
    // 模板编号: 奖励索引 :奖励ID
    private static Dictionary<int, Dictionary<int, int>> infoDict = new Dictionary<int, Dictionary<int, int>>();
    // 模板编号 奖励索引
    private static Dictionary<int, List<int>> sortDict = new Dictionary<int, List<int>>();
    protected override void OnConfigParseCompleted()
    {
        if (!infoDict.TryGetValue(TemplateID, out var dict))
        {
            dict = new Dictionary<int, int>();
            infoDict[TemplateID] = dict;
        }
        dict[AwardIndex] = AwardID;
    }
 
    private static void LoadSortList()
    {
        if (!sortDict.IsNullOrEmpty()) return;
        foreach (var kvp in infoDict)
        {
            int templateID = kvp.Key;
            List<int> list = new List<int>(kvp.Value.Keys);
            list.Sort();
            sortDict[templateID] = list;
        }
    }
 
    public static List<int> GetAwardIndexSortList(int templateID)
    {
        LoadSortList();
        sortDict.TryGetValue(templateID, out var list);
        return list;
    }
    
    public static Dictionary<int, int> GetTemplateIDDict(int templateID)
    {
        infoDict.TryGetValue(templateID, out var dict);
        return dict;
    }
 
    public static int GetID(int templateID, int awardIndex)
    {
        var dict = GetTemplateIDDict(templateID);
        if (dict == null) return 0;
 
        dict.TryGetValue(awardIndex, out var id);
        return id;
    }
 
    public static ActTotalRechargeTempConfig GetConfig(int templateID, int awardIndex)
    {
        int id = GetID(templateID, awardIndex);
        return Get(id);
    }
 
}