少年修仙传客户端代码仓库
hch
2025-07-24 50e53441950268933694eeb5aad36147bbe1014d
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
 
class SpiritEquipModel : ILModel<SpiritEquipModel>
{
    const int SpiritEquRedPointID = 119;
    const int SpiritBagRedPointID = 11901;
    const int SpiritBreachRedpointID = 11902;
    const int FosterRedpointID = 1910239;
 
 
    PackModel packModel;
 
    RoleEquipType[] equTypes = new RoleEquipType[]
    {
       RoleEquipType.Guard,
       RoleEquipType.Wing,
       RoleEquipType.PeerlessWeapon1,
       RoleEquipType.PeerlessWeapon2,
    };
 
    Redpoint spiritEquRedPoint;
    Redpoint spiritBagRedPoint;
    Redpoint spiritBreachRedPoint;
    Redpoint FosterRedPoint;
 
    public Redpoint breachBtnRedPoint;
    public Dictionary<int, Redpoint> redPoints;
    
    public List<ItemModel> showItemTable = new List<ItemModel>();
    List<int> relatedItems = new List<int>();
 
    public event Action refreshShowItemEvent;
    public event Action<int> UpdateShowWindow
        ;
    public RoleEquipType curEquType;
    public bool IsEquipBreachOpen = false;
    public int beforeBeachItemID;
    public int afterBeachItemID;
    public Dictionary<int, bool> redCheckDic = new Dictionary<int, bool>();
    public Dictionary<int, bool> redBreachDic = new Dictionary<int, bool>();
    protected override void Init()
    {
        this.SetRelatedItems();
        packModel = ModelCenter.Instance.GetModel<PackModel>();
        packModel.refreshItemCountEvent += OnRelatedItemsChange;
        GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
 
        spiritEquRedPoint = new Redpoint(1, SpiritEquRedPointID);
        spiritBagRedPoint = new Redpoint(SpiritEquRedPointID, SpiritBagRedPointID);
        spiritBreachRedPoint = new Redpoint(SpiritEquRedPointID, SpiritBreachRedpointID);
        FosterRedPoint = new Redpoint(SpiritBreachRedpointID, FosterRedpointID);
        redPoints = new Dictionary<int, Redpoint>();
        for (int i = 0; i < equTypes.Length; i++)
        {
            var type = equTypes[i];
            redPoints.Add((int)type, new Redpoint(SpiritBreachRedpointID,1910200 + (int)type));
            redCheckDic.Add((int)type, false);
            redBreachDic.Add((int)type, false);
        }
        breachBtnRedPoint = new Redpoint(SpiritBreachRedpointID,1910230);
 
        for (int i = 0; i < equTypes.Length; i++)
        {
            var type = equTypes[i];
            for (int j = 0; j < GeneralDefine.LingQiTrainIDList[(int)type].Count; j++)
            {
                int id = GeneralDefine.LingQiTrainIDList[(int)type][j];
                if (this.relatedItems.Contains(id) == false)
                    this.relatedItems.Add(id);
            }
        }
    }
 
    protected override void UnInit()
    {
        packModel.refreshItemCountEvent -= OnRelatedItemsChange;
        GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
    }
 
    void OnPlayerLoginOk()
    {
        this.RefreshShowItemTable();
        DayRemind.Instance.SetDayRemind("SpiritEquipOverdueRemind");
        this.UpdateRedPoint();
 
        SinglePack singPack = packModel.GetSinglePack(PackType.Item);
        if (singPack == null) return;
        var packItemsDict = singPack.GetAllItems();
        var keys = packItemsDict.Keys.ToList();
        //for (var index in singPack.GetAllItems().Keys)
        for (int i = 0; i < keys.Count; i++)
        {
            OnRelatedItemsChange(singPack.type, keys[i], packItemsDict[keys[i]].itemId);
        }
    }
    public void CallUpdateShowWindow(int _ID)
    {
        if (UpdateShowWindow != null)
            UpdateShowWindow(_ID);
    }
    public ItemTipUtility.BaseProperty GetBaseProperty(int itemId)
    {
        var baseProperties = new List<Int2>();
        var config = ItemConfig.Get(itemId);
        if (config.Effect1 == 220)
            return this.GetBaseProperty(config.EffectValueA1);
 
        if (ItemLogicUtility.Instance.IsDogzEquip(itemId) == false && config.Effect1 != 0)
            baseProperties.Add(new Int2(config.Effect1, config.EffectValueA1));
 
        if (config.Effect2 != 0)
            baseProperties.Add(new Int2(config.Effect2, config.EffectValueA2));
 
        if (config.Effect3 != 0)
            baseProperties.Add(new Int2(config.Effect3, config.EffectValueA3));
 
        if (config.Effect4 != 0)
            baseProperties.Add(new Int2(config.Effect4, config.EffectValueA4));
 
        if (config.Effect5 != 0)
            baseProperties.Add(new Int2(config.Effect5, config.EffectValueA5));
 
        var baseProperty = new ItemTipUtility.BaseProperty();
        baseProperty.baseProperties = baseProperties;
        return baseProperty;
    }
 
    void SetRemind()
    {
        DayRemind.Instance.SetDayRemind("SpiritEquipOverdueRemind", true);
        this.UpdateRedPoint();
    }
 
    public void UpdateRedPoint()
    {
        var bodyEquScores = new Dictionary<int, int>();
        var bHasEquCanUp = false;
        var bHasBetterEqu = false;
        for (int i = 0; i < equTypes.Length; i++)
        {
            var palce = new Int2(0, (int)equTypes[i]);
            var index = EquipSet.ClientPlaceToServerPlace(palce);
            var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
            var score = 0;
            SpiritWeaponConfig config = null;
            var bIsEquCanUp = false;
            if (itemModel != null)
                config = SpiritWeaponConfig.Get(itemModel.itemId);
            if (config != null)
            {
                score = config.AttrScore;
                if (config.UpCostItem.Length > 0)
                    bIsEquCanUp = true;
                for (int t = 0; t < config.UpCostItem.Length; t++)
                {
                    var costItemId = config.UpCostItem[t].x;
                    var reamianCount = this.packModel.GetItemCountByID(PackType.Item, costItemId);
                    if (reamianCount < config.UpCostItem[t].y)
                    {
                        bIsEquCanUp = false;
                        break;
                    }
                }
            }
            int type = (int)equTypes[i];
            bodyEquScores[type] = score;
            if (bIsEquCanUp)
            {
                bHasEquCanUp = true;
                this.redPoints[type].state = RedPointState.Simple;
                redBreachDic[type] = true;
            }
            else
            {
                this.redPoints[type].state = RedPointState.None;
                redBreachDic[type] = false;
            }
                
            //设置培养红点            
            redCheckDic[type] = FosterModel.Instance.GetLingQiRedPointUpdate(type);
            this.redPoints[type].state = RedPointState.None;
            if (config == null)
                redCheckDic[type] = false;
        }
 
        var isOnlyOverdue = true;
        for (int i = 0; i < showItemTable.Count; i++)
        {
            var itemId = showItemTable[i].itemId;
            if (!ItemLogicUtility.Instance.IsOverdue(showItemTable[i].guid))
                isOnlyOverdue = false;
            if (SpiritWeaponConfig.Has(itemId))
            {
                var place = ItemConfig.Get(itemId).EquipPlace;
                var score = SpiritWeaponConfig.Get(itemId).AttrScore;
                if (score > bodyEquScores[place])
                {
                    bHasBetterEqu = true;
                    break;
                }
            }
        }
 
       
        if (bHasEquCanUp)
            this.spiritBreachRedPoint.state = RedPointState.Simple;
        else
            this.spiritBreachRedPoint.state = RedPointState.None;
 
        if (bHasBetterEqu && isOnlyOverdue)
            bHasBetterEqu = !DayRemind.Instance.GetDayRemind("SpiritEquipOverdueRemind");
 
        if (bHasBetterEqu)
            this.spiritBagRedPoint.state = RedPointState.Simple;
        else
            this.spiritBagRedPoint.state = RedPointState.None;
 
        FosterRedPoint.state = RedPointState.None;
        for (int i = 0; i < equTypes.Length; i++)
        {
            int type = (int)equTypes[i];
            if (redCheckDic[type])
            {
                FosterRedPoint.state = RedPointState.Simple;
                this.redPoints[type].state = RedPointState.Simple;
            }
        }
    }
    public void ShowFosterRedPoint(int EquipID)
    {
        FosterRedPoint.state = RedPointState.None;
        if(redCheckDic[EquipID])
            FosterRedPoint.state = RedPointState.Simple;
    }
    void SetRelatedItems()
    {
        var configs = SpiritWeaponConfig.GetValues();
        for (int i = 0; i < configs.Count; i++)
        {
            var config = configs[i];
            if (this.relatedItems.Contains(config.ItemID) == false)
                this.relatedItems.Add(config.ItemID);
            for (int j = 0; j < config.UpCostItem.Length; j++)
            {
                var item = config.UpCostItem[j];
                if (this.relatedItems.Contains(item.x) == false)
                    this.relatedItems.Add(item.x);
            }
        }       
       
        DebugEx.LogFormat("SetRelatedItems:{0}", relatedItems.Count);
    }
 
    void OnRelatedItemsChange(PackType type, int index, int id)
    {
        //DebugEx.LogFormat("OnRelatedItemsChange:{0},{0}", id,this.relatedItems.Contains(id));        
        if (!this.relatedItems.Contains(id))
            return;
        this.RefreshShowItemTable();
        this.UpdateRedPoint();
        refreshShowItemEvent?.Invoke();
    }
 
    void RefreshShowItemTable()
    {
        this.showItemTable.Clear();
        var firstMatIndex = 0;
        for (int i = 0; i < this.relatedItems.Count; i++)
        {
            var item = relatedItems[i];
            var itemModelList = this.packModel.GetItemsById(PackType.Item, item);
 
            for (int j = 0; j < itemModelList.Count; j++)
            {
                var model = itemModelList[j];
                var bIsEqu = SpiritWeaponConfig.Has(model.itemId);
                if (bIsEqu == false)
                    this.showItemTable.Add(model);
                else
                {
                    this.showItemTable.Insert(firstMatIndex, model);
                    firstMatIndex++;
                }
            }
        }
    }
 
    public void SendBreachInfo(RoleEquipType equType)
    {
        this.curEquType = equType;
        var place = new Int2(0, (int)equType);
        var index = EquipSet.ClientPlaceToServerPlace(place);
        var itemModel = this.packModel.GetItemByIndex(PackType.Equip, index);
        this.beforeBeachItemID = itemModel.itemId;
        var info = new IL_CA318_tagCMLingQiEquipBreak();
        info.ItemID = (uint)this.beforeBeachItemID;
        GameNetSystem.Instance.SendInfo(info);
    }
 
    public void ReciveBreachResult(IL_HA815_tagMCLingQiEquipBreakResult info)
    {
        this.afterBeachItemID = (int)info.MakeItemID;
        WindowCenter.Instance.OpenIL<BreachSuccessWin>();
    }
 
}