yyl
4 天以前 c124d98bdf9659cf764bebb799bee42c30eb152f
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System;
using System.Collections.Generic;
using UnityEngine;
 
public partial class GuideConfig : ConfigBase<int, GuideConfig>
{
    public static Dictionary<string, List<int>> winToGuidesDic = new Dictionary<string, List<int>>();
 
    public static Dictionary<int, List<int>> typeToGuidesDic = new Dictionary<int, List<int>>();
 
    public static Dictionary<int, List<int>> guideGroupDict = new Dictionary<int, List<int>>();
    static Dictionary<int, int> preGuideDict = new Dictionary<int, int>();
    protected override void OnConfigParseCompleted()
    {
        base.OnConfigParseCompleted();
 
        List<int> list = null;
        if (!winToGuidesDic.TryGetValue(WinName, out list))
        {
            list = new List<int>();
            winToGuidesDic.Add(WinName, list);
        }
        list.Add(ID);
 
        List<int> list2 = null;
        if (!typeToGuidesDic.TryGetValue(TriggerType, out list2))
        {
            list2 = new List<int>();
            typeToGuidesDic.Add(TriggerType, list2);
        }
        list2.Add(ID);
 
        preGuideDict[ID] = PreGuideId;
    }
 
 
    public static List<int> GetGuideListByWinName(string winName)
    {
        List<int> list = null;
        if (winToGuidesDic.TryGetValue(winName, out list))
        {
            return list;
        }
        return null;
    }
 
    public static List<int> GetGuideListByType(int type)
    {
        List<int> list = null;
        if (typeToGuidesDic.TryGetValue(type, out list))
        {
            return list;
        }
        return null;
    }
 
 
 
 
    // 汇总引导组
    public static List<int> GetGuideList(int guideID)
    {
        if (guideGroupDict.IsNullOrEmpty())
        {
            BuildGuideGroupDict();
        }
 
        if (guideGroupDict.ContainsKey(guideID))
        {
            return guideGroupDict[guideID];
        }
        else
        {
            Debug.LogError($"guideID:{guideID} 没有找到引导组");
        }
        return null;
    }
    
    private static void BuildGuideGroupDict()
    {
        foreach (var id in preGuideDict.Keys)
        {
            int currentId = id;
            int rootId = FindRootGuideId(currentId);
 
            if (!guideGroupDict.ContainsKey(rootId))
            {
                guideGroupDict[rootId] = new List<int>();
            }
 
            if (!guideGroupDict[rootId].Contains(currentId))
            {
                guideGroupDict[rootId].Add(currentId);
            }
        }
    }
 
    private static int FindRootGuideId(int id)
    {
        int currentId = id;
        while (preGuideDict.ContainsKey(currentId) && preGuideDict[currentId] != 0)
        {
            currentId = preGuideDict[currentId];
        }
        return currentId;
    }
}