hch
2025-06-19 5022f4efe76121df33dc81249befa7556e535418
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
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
 
 
/** 玩家仙盟相关信息缓存数据 */
public class PlayerFairyData
{
    private bool hasFairy = false;
    public bool HasFairy
    {
        get { return hasFairy; }
    }
 
    public int presentFairyCount { get; set; }
 
 
 
    public FairyData fairy = null;
    public FairyMember mine = null;
    public event Action OnRefreshFairyInfo;
    public event Action OnRefreshFairyMine;
    private Dictionary<int, FairyMember> memberDic = new Dictionary<int, FairyMember>();
    private List<FairyMember> eliteList = new List<FairyMember>();
    public List<FairyMember> GetEliteList()
    {
        return eliteList;
    }
    /// <summary>
    /// 副盟主
    /// </summary>
    private List<FairyMember> deputyLeaderList = new List<FairyMember>();
    public List<FairyMember> GetDeputyLeaderList()
    {
        return deputyLeaderList;
    }
 
    public void OnRefreshFairy(H0F03_tagRoleFamilyInfo vNetData)
    {
        if (fairy == null)
        {
            fairy = new FairyData();
        }
        fairy.FamilyID = vNetData.FamilyID;
        if (fairy.FamilyID != 0) hasFairy = true;
        fairy.FamilyName = vNetData.FamilyName;
        fairy.FamilyLV = vNetData.FamilyLV;
        fairy.FamilyMoney = vNetData.FamilyMoney;
        fairy.FamilyHornor = vNetData.FamilyHornor;
        fairy.MemberCount = vNetData.MemberCount;
        fairy.Broadcast = vNetData.Broadcast;
        fairy.WarRank = vNetData.Point;
        fairy.FamilyActiveValue = vNetData.FamilyActiveValue;
        fairy.LastWeekFamilyActiveValue = vNetData.LastWeekFamilyActiveValue;
        fairy.Extra1 = vNetData.Extra1;
        fairy.Extra2 = vNetData.Extra2;
        fairy.Extra3 = vNetData.Extra3;
        fairy.Extra4 = vNetData.Extra4;
        fairy.Extra5 = vNetData.Extra5;
        fairy.Extra6 = vNetData.Extra6;
        fairy.AcceptJoin = vNetData.AcceptJoin;
 
        if (fairy.Member == null)
        {
            fairy.Member = new List<FairyMember>();
        }
 
        mine = null;
 
        memberDic.Clear();
        deputyLeaderList.Clear();
        eliteList.Clear();
        for (int i = 0; i < vNetData.MemberCount; i++)
        {
            FairyMember member = null;
            if (i >= fairy.Member.Count)
            {
                member = new FairyMember();
                fairy.Member.Add(member);
            }
            else
            {
                member = fairy.Member[i];
            }
            member.PlayerID = vNetData.Member[i].PlayerID;
            member.Sex = vNetData.Member[i].Sex;
            member.Name = UIHelper.ServerStringTrim(vNetData.Member[i].Name);
            member.LV = vNetData.Member[i].LV;
            member.ReincarnationLv = vNetData.Member[i].ReincarnationLv;
            member.FamilyLV = vNetData.Member[i].FamilyLV;
            member.FamilyName = UIHelper.ServerStringTrim(vNetData.Member[i].FamilyName);
            member.Job = vNetData.Member[i].Job;
            member.Face = vNetData.Member[i].Face;
            member.FacePic = vNetData.Member[i].FacePic;
            member.FamilyActiveValue = vNetData.Member[i].FamilyActiveValue;
            member.LastWeekFamilyActiveValue = vNetData.Member[i].LastWeekFamilyActiveValue;
            member.OperateInfo = vNetData.Member[i].OperateInfo;
            member.OfficialRank = vNetData.Member[i].OfficialRank;
            member.Exattr1 = vNetData.Member[i].Exattr1;
            member.Exattr2 = vNetData.Member[i].Exattr2;
            member.Exattr3 = vNetData.Member[i].Exattr3 + vNetData.Member[i].Exattr5 * (long)Constants.ExpPointValue;
            member.Exattr4 = vNetData.Member[i].Exattr4;
            member.Exattr5 = vNetData.Member[i].Exattr5;
 
            memberDic.Add((int)member.PlayerID, member);
 
            if (member.PlayerID == PlayerDatas.Instance.baseData.PlayerID)
            {//自己
                mine = member;
            }
 
            if (member.FamilyLV == 1)
            {
                eliteList.Add(member);
            }
            else if (member.FamilyLV == 2)
            {
                deputyLeaderList.Add(member);
            }
            else if (member.FamilyLV == 3)
            {
                Leader = member;
            }
        }
 
        for (int i = fairy.Member.Count - 1; i >= vNetData.MemberCount; i--)
        {
            FairyMember member = fairy.Member[i];
            fairy.Member.RemoveAt(i);
            member = null;
        }
 
        if (OnRefreshFairyInfo != null) OnRefreshFairyInfo();
    }
 
    public FairyMember GetMember(int playerid)
    {
        FairyMember member = null;
        memberDic.TryGetValue(playerid, out member);
        return member;
    }
 
    public FairyMember Leader
    {
        get;
        private set;
    }
    #region 仙盟列表
    private bool isSearching = false;
    public bool IsSearching
    {
        get { return isSearching; }
    }
    public const int PageCnt = 20;
 
 
    public event Action OnRefreshFairyList;
    public event Action OnRefreshFairySearch;
 
    private Dictionary<int, List<FairyData>> fairyList = new Dictionary<int, List<FairyData>>();
 
    private List<FairyData> searchList = new List<FairyData>();
    public void OnRefreshFairy(HA408_tagGCPyAllFamilyView vNetData)
    {
        if (vNetData.IsSearching == 100)
        {
            return;
        }
 
        isSearching = vNetData.IsSearching == 1;
 
        if (isSearching)
        {
            searchList.Clear();
            for (int i = 0; i < vNetData.PageCount; i++)
            {
                FairyData data = null;
                if (i >= searchList.Count)
                {
                    data = new FairyData();
                    searchList.Add(data);
                }
                HA408_tagGCPyAllFamilyView.tagGCPyFamilyView view = vNetData.Family[i];
                SetFairyViewData(data, view);
            }
            if (OnRefreshFairySearch != null) OnRefreshFairySearch();
            return;
        }
        List<FairyData> list = null;
        fairyList.TryGetValue(vNetData.CurPage, out list);
        if (list == null)
        {
            list = new List<FairyData>(PageCnt);
            fairyList.Add(vNetData.CurPage, list);
        }
        list.Clear();
        for (int i = 0; i < vNetData.PageCount; i++)
        {
            FairyData data = null;
            if (i >= list.Count)
            {
                data = new FairyData();
                list.Add(data);
            }
            HA408_tagGCPyAllFamilyView.tagGCPyFamilyView view = vNetData.Family[i];
            SetFairyViewData(data, view);
        }
        presentFairyCount = 0;
        foreach (var _list in fairyList.Values)
        {
            presentFairyCount += _list.Count;
        }
        if (OnRefreshFairyList != null)
        {
            OnRefreshFairyList();
        }
        FairyModel.Instance.UpdateAddFairyRedpoint();
    }
 
    public List<FairyData> GetSearchFairy()
    {
        return searchList;
    }
 
    public static void SetFairyViewData(FairyData data, HA408_tagGCPyAllFamilyView.tagGCPyFamilyView view)
    {
        data.FamilyID = view.FamilyID;
        data.FamilyIndex = view.FamilyIndex;
        data.FamilyName = view.FamilyName;
        data.leaderID = view.LeaderID;
        data.leaderName = view.LeaderName;
        data.FamilyLV = view.FamilyLV;
        data.MemberCount = view.FamilyMemberCount;
        data.OfficialRank = view.LeaderOfficialRank;
        data.AcceptJoin = view.JoinAccept;
        data.totalFightPower = (ulong)view.TotalFightPowerEx * Constants.ExpPointValue + view.TotalFightPower;
        data.WarRank = view.WarRank;
        data.EmblemID = view.EmblemID;
}
 
    public void OnRefreshFairy(H0430_tagPlayerInFamilyInfoRefresh vNetData)
    {
        if (vNetData.FamilyNameLen > 0)
        {
            if (fairy == null)
            {
                fairy = new FairyData();
            }
 
            if (mine != null)
            {
                mine.FamilyLV = vNetData.FamilyMemberLV;
            }
        }
        else
        {
            ClearFairyData();
            LocalChatHistory.Clear(ChatInfoType.Fairy);
            // WindowCenter.Instance.Close<UnionPanel>();
        }
        if (OnRefreshFairyMine != null)
        {
            OnRefreshFairyMine();
        }
        UpdateRequestRedpoint();
    }
 
    public void OnRefreshFairy(H0F05_tagFamilyChange vNetData)
    {
        FairyModel.Instance.UpdateFairyInfo();
    }
 
    public void ClearFairyList()
    {
        fairyList.Clear();
    }
 
    public List<FairyData> GetFairyListByPage(int page)
    {
        List<FairyData> list = null;
        fairyList.TryGetValue(page, out list);
        return list;
    }
 
    public void ClearFairyData()
    {
        hasFairy = false;
        fairy = null;
        mine = null;
        applyList.Clear();
        //ChatCtrl.Inst.ClearChatInfo(ChatInfoType.Fairy);
    }
    #endregion
 
    #region 申请列表
    public event Action OnRefreshApplyList;
    private List<FairyApply> applyList = new List<FairyApply>();
    private Redpoint applyRedpoint = new Redpoint(10702, 1070201);
    private Redpoint memberRedpoint = new Redpoint(107, 10702);
    public void OnRefreshFairy(HA401_tagGCViewFamilyRequestInfo vNetData)
    {
        applyList.Clear();
        for (int i = 0; i < vNetData.RequestMemberCount; i++)
        {
            FairyApply apply = new FairyApply();
            apply.Name = vNetData.MemberInfo[i].Name;
            apply.PlayerID = vNetData.MemberInfo[i].PlayerID;
            apply.PlayerLV = vNetData.MemberInfo[i].PlayerLV;
            apply.PlayeJob = vNetData.MemberInfo[i].PlayeJob;
            apply.PlayeFightPower = vNetData.MemberInfo[i].PlayeFightPower + vNetData.MemberInfo[i].PlayeFightPowerEx * (long)Constants.ExpPointValue;
            apply.RequestTime = vNetData.MemberInfo[i].RequestTime;
            apply.IsOnLine = vNetData.MemberInfo[i].IsOnLine;
            applyList.Add(apply);
        }
        if (OnRefreshApplyList != null)
        {
            OnRefreshApplyList();
        }
        UpdateRequestRedpoint();
    }
 
    void UpdateRequestRedpoint()
    {
        if (HasFairy && IsCanFunc(LimitFunc.CanCall))
        {
            applyRedpoint.state = applyList.Count > 0 ? RedPointState.Simple : RedPointState.None;
        }
        else
        {
            applyRedpoint.state = RedPointState.None;
        }
    }
 
    public List<FairyApply> GetApplyList()
    {
        return applyList;
    }
    #endregion
 
 
 
    #region 仙盟权力开启条件
    public int[] funcArray = null;
    public bool IsCanFunc(LimitFunc funcType)
    {
        // if (funcArray == null)
        // {
        //     funcArray = ConfigParse.GetMultipleStr<int>(FuncConfigConfig.Get("FamilyPurview").Numerical1);
        // }
        // if (funcArray != null && funcArray.Length > 6)
        // {
        //     if (mine != null)
        //     {
        //         return mine.FamilyLV >= funcArray[(int)funcType];
        //     }
        // }
        return false;
    }
    #endregion
 
    public class FairyData
    {
        public uint FamilyID;
        public string FamilyName;    //家族名称
        public ushort FamilyLV;    //家族等级
        public uint FamilyMoney;    //资金
        public uint FamilyHornor;    //荣誉
        public ushort MemberCount;    //人数
        public uint Point;    //家族战积分
        public string Broadcast;    //size = BroadcastLen
        public uint FamilyActiveValue;    //本周家族活跃度
        public uint LastWeekFamilyActiveValue;    //上周家族活跃度    
        public List<FairyMember> Member = null;    //size = MemberCount
        public uint Extra1;    //附加字段1
        public uint Extra2;    //附加字段2
        public uint Extra3;    //附加字段3
        public uint Extra4;    //附加字段4
        public uint Extra5;    //附加字段5
        public uint Extra6;    //附加字段6 仙盟当前佩戴的徽章ID
        public byte AcceptJoin;    //是否接受申请
        public uint WarRank;  //仙盟联赛排名
        public ulong totalFightPower;
        public int EmblemID;  //仙盟徽章ID
        #region 查找专用字段
        public ushort FamilyIndex;
        public uint leaderID;
        public string leaderName;
        public byte OfficialRank;        //境界
        #endregion
    }
 
    public class FairyMember
    {
        public uint PlayerID;
        public byte Sex;        //性别
        public string Name;        //size = NameLen
        public ushort LV;
        public ushort ReincarnationLv;
        public byte FamilyLV;        //家族等级
        public string FamilyName;        //size = FamilyNameLen
        public byte Job;        //职业
        public uint Face;        //头像
        public uint FacePic;        //头像外框
        public byte OfficialRank;        //境界
        public uint FamilyActiveValue;        //本周家族活跃度
        public uint LastWeekFamilyActiveValue;        //上周家族活跃度    
        public uint Exattr1;        //扩展属性
        public uint Exattr2;        //每周仙盟资金上限
        public long Exattr3;        //扩展属性
        public uint Exattr4;        //扩展属性
        public uint Exattr5;        //扩展属性
        public uint OperateInfo;        //玩家附加运营商信息
    }
 
    public class FairyApply
    {
        public uint PlayerID;        //玩家ID
        public string Name;        //size=NameLen
        public ushort PlayerLV;        //玩家等级
        public byte PlayeJob;        //玩家职业
        public long PlayeFightPower;        //玩家战斗力
        public uint RequestTime;        //申请时间
        public byte IsOnLine;        //是否在线
    }
 
    public enum LimitFunc
    {
        CanCall = 0,
        CanJobTitle = 1,
        CanNotify = 2,
        CanLvUp = 3,
        CanClearTreasury = 4,
        CanKick = 5,
        CanOpenBoss = 6,
    }
}