少年修仙传客户端代码仓库
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
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
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
    
    public class BossFirstBloodModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
    {
 
 
        ImpactRankModel impactRankModel
        {
            get
            {
                return ModelCenter.Instance.GetModel<ImpactRankModel>();
            }
        }
 
        public int selectIndex = 0;
        public int selectNPCID = 0;
 
        public struct FirstKillTimeInfo
        {
            public string name;
            public string time;
        }
 
        Dictionary<int, int> FirstKillStateInfo = new Dictionary<int, int>(); // 击杀奖励状态
        public Dictionary<int, FirstKillTimeInfo> firstKillTimeInfo = new Dictionary<int, FirstKillTimeInfo>(); // 首杀名和时间
        private Dictionary<int, Redpoint> m_Redpoints = new Dictionary<int, Redpoint>();
        private Dictionary<int, Redpoint> m_RedPackRedpoints = new Dictionary<int, Redpoint>();
 
        public List<string> npcIDConfig;
        public bool IsOpen
        {
            get
            {
                return impactRankModel.IsOpen;
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                //var state = impactRankRedpoint.state;
                //return state == RedPointState.Simple || state == RedPointState.GetReward;
                return false;
            }
        }
 
        public const int Redpoint_BossKillRank = 25900;
        public Redpoint rankRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENRANK, Redpoint_BossKillRank);
 
        public bool IsAdvance
        {
            get
            {
                return false;
            }
        }
 
        
        public Int2 GetFirstNPCRedPoint()
        {
            //先找红点,没有红点则找最低级未领奖励的BOSS
            Int2 npcinfo = Int2.zero;
            int i = 0;
            foreach (var key in npcIDConfig)
            {
                var npcID = int.Parse(key);
                var _redpoint = m_Redpoints[npcID];
                if (_redpoint.state != RedPointState.None)
                {
                    npcinfo.x = i;
                    npcinfo.y = npcID;
                    return npcinfo;
                }
                i++;
            }
            i = 0;
            foreach (var key in npcIDConfig)
            {
                var npcID = int.Parse(key);
                var state = GetPersonalKillAwardState(npcID);
                if (GetPersonalKillAwardState(npcID) != 2)
                {
                    npcinfo.x = i;
                    npcinfo.y = npcID;
                    return npcinfo;
                }
                i++;
            }
            return npcinfo;
        }
 
        public void UpdateAllRedPoint()
        {
            foreach (var _key in m_Redpoints.Keys)
            {
                UpdateRedPoint(_key, GetPersonalKillAwardState(_key) == 1 ? RedPointState.Simple : RedPointState.None);
            }
        }
 
        public void UpdateRedPoint(int npcID, RedPointState state)
        {
            var _redpoint = m_Redpoints[npcID];
            
            _redpoint.state = m_RedPackRedpoints[npcID].state == RedPointState.None ? state : m_RedPackRedpoints[npcID].state;
        }
 
 
        public event Action<int> onStateUpdate;
 
        public override void Init()
        {
            OpenServerActivityCenter.Instance.Register(100, this);
            InitNpcInfo();
            DTCA003_tagUniversalGameRecInfo.onGetUniversalGameInfo += OnGetUniversalGameInfo;
        }
        private void SendGameRec()
        {
            var pak = new CA001_tagViewUniversalGameRec();
            pak.ViewType = 31;
            GameNetSystem.Instance.SendInfo(pak);
        }
        public event Action<int> OnFirstKillInfo;
        private void OnGetUniversalGameInfo(HA003_tagUniversalGameRecInfo package)
        {
            if (package.Type == 31)
            {
                for (int i = 0; i < package.Count; i++)
                {
                    int npcID = (int)package.UniversalGameRec[i].Value1;
                    firstKillTimeInfo[(int)package.UniversalGameRec[i].Value1] = new FirstKillTimeInfo()
                    {
                        name = package.UniversalGameRec[i].StrValue3,
                        time = package.UniversalGameRec[i].StrValue2,
 
                    };
                    if (!WindowCenter.Instance.IsOpen<BossFirstBloodWin>() && OnFirstKillInfo != null)
                        OnFirstKillInfo(npcID);
                }
                UpdateAllRedPackPoint();
                UpdateAllRedPoint();
            }
 
        }
 
        public int GetBossKillAwardState(int npcID)
        {
            //0 未击杀 1 可领取 2 已领取
            if (firstKillTimeInfo.ContainsKey(npcID) && !string.IsNullOrEmpty(firstKillTimeInfo[npcID].name))
            {
                //无数据为可领取
                if (!FirstKillStateInfo.ContainsKey(npcID)) return 1; 
 
                int state = FirstKillStateInfo[npcID];
                if (state/10 % 10 == 0)
                    return 1;
                else
                    return 2;
            }
            return 0;
        }
        public void UpdateAllRedPackPoint()
        {
            foreach (var _key in m_RedPackRedpoints.Keys)
            {
                UpdateRedPackPoint(_key);
            }
        }
 
        public void UpdateRedPackPoint(int npcID)
        {
            var state = GetBossKillAwardState(npcID) == 1 ? RedPointState.Simple : RedPointState.None;
            m_RedPackRedpoints[npcID].state = state;
 
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            FirstKillStateInfo.Clear();
            firstKillTimeInfo.Clear();
        }
 
        public void OnPlayerLoginOk()
        {
            SendGameRec();
        }
 
        public void InitNpcInfo()
        {
            npcIDConfig = BOSSFirstKillConfig.GetKeys();
            npcIDConfig.Sort((string x, string y) =>
            {
                var infoX = BOSSFirstKillConfig.Get(x);
                var infoY = BOSSFirstKillConfig.Get(y);
                return infoX.Sort.CompareTo(infoY.Sort);
            });
 
            foreach (var key in npcIDConfig)
            {
                var npcID = int.Parse(key);
                var infoX = BOSSFirstKillConfig.Get(key);
                m_Redpoints.Add(npcID, new Redpoint(Redpoint_BossKillRank, Redpoint_BossKillRank * 100 + infoX.Sort));
                m_RedPackRedpoints.Add(npcID, new Redpoint(Redpoint_BossKillRank * 100 + infoX.Sort, (Redpoint_BossKillRank * 100 + infoX.Sort)*10));
 
            }
        }
 
        public int GetNPCRedPackPointID(int npcID)
        {
            var infoX = BOSSFirstKillConfig.Get(npcID);
            return (Redpoint_BossKillRank * 100 + infoX.Sort) * 10;
 
        }
 
        public override void UnInit()
        {
            DTCA003_tagUniversalGameRecInfo.onGetUniversalGameInfo -= OnGetUniversalGameInfo;
        }
        public event Action<int> UpdatePersonnalKillEvent;
        public void BossFirstKillStateInfo(HAB01_tagMCBossFirstKillStateInfo package)
        {
            for (int i=0; i < package.BossCount; i++)
            {
                FirstKillStateInfo[(int)package.FirstKillStateList[i].NPCID] = (int)package.FirstKillStateList[i].FKState;
                if (UpdatePersonnalKillEvent != null)
                    UpdatePersonnalKillEvent((int)package.FirstKillStateList[i].NPCID);
            }
            UpdateAllRedPackPoint();
            UpdateAllRedPoint();
        }
 
        public int GetPersonalKillAwardState(int npcID)
        {
            //0 未击杀 1 可领取 2 已领取
            if (FirstKillStateInfo.ContainsKey(npcID))
            {
                int state = FirstKillStateInfo[npcID];
                if (state % 10 == 0)
                    return 0;
                if (state % 10 > 0 && state/100 == 0)
                    return 1;
                if (state % 10 > 0 && state / 100 == 1)
                    return 2;
            }
            return 0;
        }
 
        public bool IsAlreadyFirstKill(int npcID)
        {
            if (firstKillTimeInfo.ContainsKey(npcID))
                return true;
            return false;
        }
    }
}