hch
1 天以前 89fa96e505af9fe7baf676591222bfdb23b48262
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections.Generic;
// 默认ID相关
public partial class PhantasmPavilionManager : GameSystemManager<PhantasmPavilionManager>
{
    //<类型,<job,id>>
    public Dictionary<PhantasmPavilionType, Dictionary<int, int>> defaultIDDict = new Dictionary<PhantasmPavilionType, Dictionary<int, int>>();
    //<类型,id>
    public Dictionary<PhantasmPavilionType, int> nowIDDict = new Dictionary<PhantasmPavilionType, int>();
    void InitTable()
    {
        var tabValues = Enum.GetValues(typeof(PhantasmPavilionType));
        for (int i = 0; i < tabValues.Length; i++)
        {
            PhantasmPavilionType tab = (PhantasmPavilionType)tabValues.GetValue(i);
            if (!defaultIDDict.ContainsKey(tab))
            {
                defaultIDDict[tab] = new Dictionary<int, int>();
            }
        }
        var config = FuncConfigConfig.Get("PhantasmPavilion");
        defaultIDDict[PhantasmPavilionType.Face] = ConfigParse.ParseIntDict(config.Numerical1);
        defaultIDDict[PhantasmPavilionType.FacePic] = ConfigParse.ParseIntDict(config.Numerical2);
        defaultIDDict[PhantasmPavilionType.ChatBox] = ConfigParse.ParseIntDict(config.Numerical3);
        defaultIDDict[PhantasmPavilionType.Model] = ConfigParse.ParseIntDict(config.Numerical4);
        //PhantasmPavilionType.Title 支持卸下,不需要保底的默认值
    }
 
    void InitNowIDDict()
    {
        nowIDDict[PhantasmPavilionType.Face] = PlayerDatas.Instance.baseData.face;
        nowIDDict[PhantasmPavilionType.FacePic] = PlayerDatas.Instance.baseData.facePic;
        nowIDDict[PhantasmPavilionType.ChatBox] = (int)PlayerDatas.Instance.baseData.chatBox;
        nowIDDict[PhantasmPavilionType.Model] = PlayerDatas.Instance.baseData.modelMark;
        nowIDDict[PhantasmPavilionType.Title] = PlayerDatas.Instance.baseData.TitleID;
    }
 
    void UpdateNowIDDict(PlayerDataType type)
    {
        bool isUpdate = true;
        PhantasmPavilionType phantasmPavilionType = PhantasmPavilionType.Face;
        switch (type)
        {
            case PlayerDataType.Face:
                phantasmPavilionType = PhantasmPavilionType.Face;
                nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.Face);
                break;
            case PlayerDataType.FacePic:
                phantasmPavilionType = PhantasmPavilionType.FacePic;
                nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.FacePic);
                break;
            case PlayerDataType.ExAttr10:
                phantasmPavilionType = PhantasmPavilionType.ChatBox;
                nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr10);
                break;
            case PlayerDataType.ModelMark:
                phantasmPavilionType = PhantasmPavilionType.Model;
                nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ModelMark);
                break;
            case PlayerDataType.ExAttr3:
                phantasmPavilionType = PhantasmPavilionType.Title;
                nowIDDict[phantasmPavilionType] = (int)PlayerDatas.Instance.GetPlayerDataByType(PlayerDataType.ExAttr3);
                break;
            default:
                isUpdate = false;
                break;
        }
 
        if (isUpdate)
        {
            if (nowType == phantasmPavilionType)
            {
                if (TryGetNowShowID(phantasmPavilionType, out int showID))
                {
                    selectId = showID;
                }
 
            }
            UpdateRedPoint();
        }
    }
 
    //获取不同职业对应的ID默认值
    public bool TryGetDefaultID(PhantasmPavilionType type, int job, out int defaultID)
    {
        defaultID = 0;
        if (defaultIDDict == null || !defaultIDDict.TryGetValue(type, out var dict) || dict == null)
            return false;
        return dict.TryGetValue(job, out defaultID) || dict.TryGetValue(0, out defaultID);
    }
 
    // 获取当前应该显示的ID
    public bool TryGetNowShowID(PhantasmPavilionType type, out int showID)
    {
        showID = 0;
        int job = PlayerDatas.Instance.baseData.Job;
 
        if (type != PhantasmPavilionType.Title)
        {
            if (!TryGetDefaultID(type, job, out int defaultID))
                return false;
 
            // 尝试获取玩家当前佩戴的ID
            bool hasEquippedID = nowIDDict.TryGetValue(type, out int equippedID);
            // 检查当前佩戴的ID是否有效
            bool isEquippedIDValid = hasEquippedID && IsUnlock(type, equippedID);
            // 如果佩戴的ID有效,则使用它;否则,回退到之前获取的默认ID
            showID = isEquippedIDValid ? equippedID : defaultID;
            return true;
        }
        else
        {
            // 尝试获取玩家当前佩戴的ID
            bool hasEquippedID = nowIDDict.TryGetValue(type, out int equippedID);
            // 检查当前佩戴的ID是否有效
            bool isEquippedIDValid = hasEquippedID && IsUnlock(type, equippedID);
            // 如果佩戴的ID有效,则使用它;否则,返回0
            showID = isEquippedIDValid ? equippedID : 0;
            return true;
        }
    }
 
    //获得形象外观ID
    public int GetModelSkinID(int id)
    {
        var config = ModelConfig.Get(id);
        if (config == null)
        {
            TryGetDefaultID(PhantasmPavilionType.Model, PlayerDatas.Instance.baseData.Job, out int defaultID);
            return ModelConfig.Get(defaultID).SkinID;
        }
        return config.SkinID;
    }
 
    public int GetMyModelSkinID()
    {
        return GetModelSkinID(PlayerDatas.Instance.baseData.modelMark);
    }
}