hch
2026-03-20 c8aea6cbef51b3dd41b4d911bc7e6bf89a6e2e2d
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
using System.Collections.Generic;
using System.Linq;
using UnityEngine.UI;
 
public partial class PhantasmPavilionManager : GameSystemManager<PhantasmPavilionManager>
{
    //头像入口用
    public Redpoint parentRedpoint = new Redpoint(MainRedDot.PhantasmPavilionRepoint);
    //内政用
    public Redpoint parentRedpoint2 = new Redpoint(MainRedDot.MainAffairsRedpoint, MainRedDot.PhantasmPavilionRepoint * 100 + (int)PhantasmPavilionRepointType.MainAffairs);
    public Dictionary<PhantasmPavilionRepointType, Redpoint> tabRedPointDict = new Dictionary<PhantasmPavilionRepointType, Redpoint>();
 
    private void InitTabRedPoint()
    {
        tabRedPointDict[PhantasmPavilionRepointType.Model] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Model));
        tabRedPointDict[PhantasmPavilionRepointType.Face] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Face));
        tabRedPointDict[PhantasmPavilionRepointType.Title] = new Redpoint(MainRedDot.PhantasmPavilionRepoint, GetRedpointId(PhantasmPavilionRepointType.Title));
        tabRedPointDict[PhantasmPavilionRepointType.ModelNormal] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Model), GetRedpointId(PhantasmPavilionRepointType.ModelNormal));
        tabRedPointDict[PhantasmPavilionRepointType.ModelEvent] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Model), GetRedpointId(PhantasmPavilionRepointType.ModelEvent));
        tabRedPointDict[PhantasmPavilionRepointType.FaceAvatar] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceAvatar));
        tabRedPointDict[PhantasmPavilionRepointType.FaceFrame] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceFrame));
        tabRedPointDict[PhantasmPavilionRepointType.FaceBubble] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Face), GetRedpointId(PhantasmPavilionRepointType.FaceBubble));
        tabRedPointDict[PhantasmPavilionRepointType.TitlePalace] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Title), GetRedpointId(PhantasmPavilionRepointType.TitlePalace));
        tabRedPointDict[PhantasmPavilionRepointType.TitleEvent] = new Redpoint(GetRedpointId(PhantasmPavilionRepointType.Title), GetRedpointId(PhantasmPavilionRepointType.TitleEvent));
    }
    public int GetRedpointId(PhantasmPavilionRepointType type)
    {
        return MainRedDot.PhantasmPavilionRepoint * 100 + (int)type;
    }
 
    void UpdateRedPointByCanActivate(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
    {
        List<int> list = ShowItemList(type, tabType);
        if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
            return;
        foreach (var id in list)
        {
            if (!Has(type, id))
                continue;
            PhantasmPavilionState state = GetUnLockState(type, id);
            if (state == PhantasmPavilionState.CanActivate)
            {
                tabRedPointDict[redType].state = RedPointState.Simple;
            }
        }
    }
 
    void UpdateRedPointByCanUpStar(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
    {
        List<int> list = ShowItemList(type, tabType);
        if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
            return;
        foreach (var id in list)
        {
            if (!Has(type, id))
                continue;
            bool isCanUpStar = CheckCanUpByItem(type, id);
            if (isCanUpStar)
            {
                tabRedPointDict[redType].state = RedPointState.Simple;
            }
        }
    }
 
    void UpdateRedPointByNoSee(PhantasmPavilionType type, PhantasmPavilionRepointType redType, int tabType = 0)
    {
        List<int> list = ShowItemList(type, tabType);
        if (list.IsNullOrEmpty() || !tabRedPointDict.ContainsKey(redType))
            return;
        foreach (var id in list)
        {
            if (!Has(type, id))
                continue;
            int unlockWay = GetUnlockWay(type, id);
            int unlockValue = GetUnlockValue(type, id);
            if (unlockWay != 3 && unlockWay != 4)
                continue;
            if (unlockWay == 3)
            {
                bool hasNewHero = HasNewHero(type, unlockValue);
                if (hasNewHero)
                {
                    tabRedPointDict[redType].state = RedPointState.Simple;
                }
            }
            else if (unlockWay == 4)
            {
                if (HasNewSkin(type, unlockValue))
                    tabRedPointDict[redType].state = RedPointState.Simple;
            }
 
        }
    }
 
    public void UpdateItemRedPoint(Image imgRed, PhantasmPavilionType type, int id)
    {
        imgRed.SetActive(false);
 
        if (!Has(type, id))
            return;
        PhantasmPavilionState state = GetUnLockState(type, id);
        if (state == PhantasmPavilionState.CanActivate)
        {
            imgRed.SetActive(true);
        }
 
        bool isCanUpStar = CheckCanUpByItem(type, id);
        if (isCanUpStar)
        {
            imgRed.SetActive(true);
        }
 
        int unlockWay = GetUnlockWay(type, id);
        if (unlockWay != 3 && unlockWay != 4)
            return;
 
        int unlockValue = GetUnlockValue(type, id);
        if (unlockWay == 3)
        {
            if (HasNewHero(type, unlockValue))
                imgRed.SetActive(true);
        }
        else if (unlockWay == 4)
        {
            if (HasNewSkin(type, unlockValue))
                imgRed.SetActive(true);
        }
 
    }
    readonly int funcId = 3;//内政
    //内政没开不刷红点
    public bool IsFuncOpen()
    {
        return FuncOpen.Instance.IsFuncOpen(funcId);
    }
    public void UpdateRedPoint()
    {
        parentRedpoint.state = RedPointState.None;
        parentRedpoint2.state = RedPointState.None;
 
        if (!tabRedPointDict.IsNullOrEmpty())
        {
            foreach (var item in tabRedPointDict)
            {
                item.Value.state = RedPointState.None;
            }
        }
 
        // 有可手动解锁的
        UpdateRedPointByCanActivate(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
        UpdateRedPointByCanActivate(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
        UpdateRedPointByCanActivate(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
        UpdateRedPointByCanActivate(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
        UpdateRedPointByCanActivate(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
        UpdateRedPointByCanActivate(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
        UpdateRedPointByCanActivate(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
 
        // 有可升级的
        UpdateRedPointByCanUpStar(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
        UpdateRedPointByCanUpStar(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
 
        // 自动解锁未查看的
        UpdateRedPointByNoSee(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelNormal, 1);
        UpdateRedPointByNoSee(PhantasmPavilionType.Model, PhantasmPavilionRepointType.ModelEvent, 2);
        UpdateRedPointByNoSee(PhantasmPavilionType.Face, PhantasmPavilionRepointType.FaceAvatar);
        UpdateRedPointByNoSee(PhantasmPavilionType.FacePic, PhantasmPavilionRepointType.FaceFrame);
        UpdateRedPointByNoSee(PhantasmPavilionType.ChatBox, PhantasmPavilionRepointType.FaceBubble);
        UpdateRedPointByNoSee(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitlePalace, 1);
        UpdateRedPointByNoSee(PhantasmPavilionType.Title, PhantasmPavilionRepointType.TitleEvent, 2);
 
 
        if (IsFuncOpen())
        {
            parentRedpoint2.state = parentRedpoint.state;
        }
    }
 
    public List<int> newSkinIDModelList = new List<int>();
    public List<int> newSkinIDFaceList = new List<int>();
    string modelSkinKey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_ModelSkin_", PlayerDatas.Instance.PlayerId.ToString()); } }
    string faceSkinKey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_FaceSkin_", PlayerDatas.Instance.PlayerId.ToString()); } }
    public void AddNewSkin(int skinID)
    {
        AddNew(newSkinIDModelList, skinID);
        AddNew(newSkinIDFaceList, skinID);
    }
    // 抽象添加逻辑
    void AddNew(List<int> list, int id)
    {
        if (list.Contains(id))
            return;
        list.Add(id);
        SaveLocal();
        UpdateRedPoint();
    }
 
    public bool HasNewSkin(PhantasmPavilionType type, int skinID)
    {
        switch (type)
        {
            case PhantasmPavilionType.Model: return newSkinIDModelList.Contains(skinID);
            case PhantasmPavilionType.Face: return newSkinIDFaceList.Contains(skinID);
            default: return false;
        }
    }
 
    public List<int> newHeroIDModelList = new List<int>();
    public List<int> newHeroIDFaceList = new List<int>();
 
    public void AddNewHero(int heroID)
    {
        AddNew(newHeroIDModelList, heroID);
        AddNew(newHeroIDFaceList, heroID);
    }
 
    public void RemoveAllNewHeroByTabType(PhantasmPavilionType type, int tabType = 0)
    {
        List<int> list = null;
        switch (type)
        {
            case PhantasmPavilionType.Model:
                list = ShowItemList(type, tabType);
                break;
            case PhantasmPavilionType.Face:
                list = GetTableKeys(type);
                break;
            default:
                return;
        }
 
        if (list.IsNullOrEmpty())
            return;
        foreach (var id in list)
        {
            RemoveNewHero(type, id, false);
        }
        SaveLocal();
    }
 
    public void RemoveNewHero(PhantasmPavilionType type, int id, bool isSave = true)
    {
        if (!Has(type, id))
            return;
        int unlockWay = GetUnlockWay(type, id);
        int unlockValue = GetUnlockValue(type, id);
        if (unlockWay != 3 && unlockWay != 4) return;
 
        switch (type)
        {
            case PhantasmPavilionType.Model:
                if (unlockWay == 3) RemoveNew(newHeroIDModelList, unlockValue, isSave);
                else if (unlockWay == 4) RemoveNew(newSkinIDModelList, unlockValue, isSave); // 皮肤
                break;
            case PhantasmPavilionType.Face:
                if (unlockWay == 3) RemoveNew(newHeroIDFaceList, unlockValue, isSave);
                else if (unlockWay == 4) RemoveNew(newSkinIDFaceList, unlockValue, isSave); // 皮肤
                break;
        }
    }
 
    void RemoveNew(List<int> list, int id, bool isSave = true)
    {
        if (!list.Contains(id)) return;
        list.Remove(id);
        if (isSave) SaveLocal();
        UpdateRedPoint();
    }
 
 
    public bool HasNewHero(PhantasmPavilionType type, int heroID)
    {
        switch (type)
        {
            case PhantasmPavilionType.Model:
                return newHeroIDModelList.Contains(heroID);
            case PhantasmPavilionType.Face:
                return newHeroIDFaceList.Contains(heroID);
            default:
                return false;
        }
 
    }
 
    string modelkey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_Model_", PlayerDatas.Instance.PlayerId.ToString()); } }
    string facekey { get { return StringUtility.Concat("PhantasmPavilion_Redponit_Face_", PlayerDatas.Instance.PlayerId.ToString()); } }
    public void SaveLocal()
    {
        LocalSave.SetIntArray(modelkey, newHeroIDModelList.ToArray());
        LocalSave.SetIntArray(facekey, newHeroIDFaceList.ToArray());
        LocalSave.SetIntArray(modelSkinKey, newSkinIDModelList.ToArray());
        LocalSave.SetIntArray(faceSkinKey, newSkinIDFaceList.ToArray());
    }
    public void LoadLocal()
    {
        LoadLocalModel();
        LoadLocalFace();
        LoadLocalSkin();
    }
 
    void LoadLocalSkin()
    {
        if (LocalSave.HasKey(modelSkinKey))
        {
            int[] arr = LocalSave.GetIntArray(modelSkinKey);
            newSkinIDModelList = arr.IsNullOrEmpty() ? new List<int>() : arr.ToList();
        }
        else
        {
            newSkinIDModelList = new List<int>();
        }
 
        if (LocalSave.HasKey(faceSkinKey))
        {
            int[] arr = LocalSave.GetIntArray(faceSkinKey);
            newSkinIDFaceList = arr.IsNullOrEmpty() ? new List<int>() : arr.ToList();
        }else
        {
            newSkinIDFaceList = new List<int>();
        }
    }
 
    void LoadLocalModel()
    {
        if (!LocalSave.HasKey(modelkey))
        {
            newHeroIDModelList = new List<int>();
            return;
        }
 
        int[] arr = LocalSave.GetIntArray(modelkey);
        if (arr.IsNullOrEmpty())
        {
            newHeroIDModelList = new List<int>();
            return;
        }
 
        newHeroIDModelList = arr.ToList();
    }
 
    void LoadLocalFace()
    {
        if (!LocalSave.HasKey(facekey))
        {
            newHeroIDFaceList = new List<int>();
            return;
        }
 
        int[] arr = LocalSave.GetIntArray(facekey);
        if (arr.IsNullOrEmpty())
        {
            newHeroIDFaceList = new List<int>();
            return;
        }
 
        newHeroIDFaceList = arr.ToList();
    }
}
 
public enum PhantasmPavilionRepointType
{
    MainAffairs = 99,  //内政入口用
 
    Model = 10,
    Face = 20,
    Title = 30,
 
    ModelNormal = 11,
    ModelEvent = 12,
 
    FaceAvatar = 21,
    FaceFrame = 22,
    FaceBubble = 23,
 
    TitlePalace = 31,
    TitleEvent = 32,
}