少年修仙传客户端代码仓库
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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using vnxbqy.UI;
 
public partial class PriorBundleConfig
{
    static Dictionary<string, PriorBundleConfig> m_Audios = new Dictionary<string, PriorBundleConfig>();
    static Dictionary<string, PriorBundleConfig> m_Effects = new Dictionary<string, PriorBundleConfig>();
    static Dictionary<string, PriorBundleConfig> m_Scenes = new Dictionary<string, PriorBundleConfig>();
    static Dictionary<string, PriorBundleConfig> m_Mobs = new Dictionary<string, PriorBundleConfig>();
    static Dictionary<string, PriorBundleConfig> m_Video = new Dictionary<string, PriorBundleConfig>();
    static Dictionary<string, PriorBundleConfig> m_UI = new Dictionary<string, PriorBundleConfig>();
    static bool categoryInited = false;
 
    static void Init()
    {
        var values = PriorBundleConfig.GetValues();
 
        foreach (var value in values)
        {
            switch (value.AssetType)
            {
                case 1:
                    m_Scenes[value.AssetABName.ToLower()] = value;
                    break;
                case 2:
                    m_Mobs[value.AssetABName.ToLower()] = value;
                    break;
                case 3:
                    m_Audios[value.AssetABName.ToLower()] = value;
                    break;
                case 4:
                    m_Effects[value.AssetABName.ToLower()] = value;
                    break;
                case 5:
                    m_Video[value.AssetABName.ToLower()] = value;
                    break;
                case 6:
                    m_UI[value.AssetABName.ToLower()] = value;
                    break;
            }
        }
 
        categoryInited = true;
    }
 
    //资源的优先级,<=1 为前置资源
    public static int GetAssetPrior(AssetVersion.AssetCategory category, string fileName)
    {
        if (!categoryInited)
        {
            Init();
        }
        fileName = fileName.ToLower();
        switch (category)
        {
            case AssetVersion.AssetCategory.Scene:
                return m_Scenes.ContainsKey(fileName) ? m_Scenes[fileName].Prior : 100;
            case AssetVersion.AssetCategory.Mob:
                return m_Mobs.ContainsKey(fileName) ? m_Mobs[fileName].Prior : 101;
            case AssetVersion.AssetCategory.Effect:
                return m_Effects.ContainsKey(fileName) ? m_Effects[fileName].Prior : 102;
            case AssetVersion.AssetCategory.Audio:
                return m_Audios.ContainsKey(fileName) ? m_Audios[fileName].Prior : 103;
            case AssetVersion.AssetCategory.Video:
                return m_Video.ContainsKey(fileName) ? m_Video[fileName].Prior : 104;
            case AssetVersion.AssetCategory.UI:
                {
 
#if UNITY_EDITOR
                    if (m_UI.ContainsKey(fileName))
                    {
                        //有配置的优先级为1的 也不包含在包内
                        if (Launch.GetLaunchStage() != 0)
                        {
                            return m_UI[fileName].Prior;
                        }
                        else
                        { 
                            return 2;
                        }
                    }
                    return 0;
#else
                    return m_UI.ContainsKey(fileName) ? m_UI[fileName].Prior : 0;
#endif
 
                }
            default:
                return 0;
        }
    }
 
    //获取资源归属的地图id
    public static int GetAssetBelongToMap(AssetVersion.AssetCategory category, string fileName)
    {
        if (!categoryInited)
        {
            Init();
        }
 
        fileName = fileName.ToLower();
        switch (category)
        {
            case AssetVersion.AssetCategory.Scene:
                return m_Scenes.ContainsKey(fileName) ? m_Scenes[fileName].mapId : 0;
            case AssetVersion.AssetCategory.Mob:
                return m_Mobs.ContainsKey(fileName) ? m_Mobs[fileName].mapId : 0;
            case AssetVersion.AssetCategory.Effect:
                return m_Effects.ContainsKey(fileName) ? m_Effects[fileName].mapId : 0;
            case AssetVersion.AssetCategory.Audio:
                return m_Audios.ContainsKey(fileName) ? m_Audios[fileName].mapId : 0;
            default:
                return 0;
        }
    }
 
 
}