少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using LitJson;
using System;
using System.Collections.Generic;
using System.Linq;
 
namespace vnxbqy.UI
{
    public class YunShiMissionActModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk, IOpenServerActivity
    {
        public event Action<int> onStateUpdate;
        public Redpoint redPoint = new Redpoint(MainRedDot.YunShiRepoint, MainRedDot.YunShiRepoint * 10 + 2); //¿ÉÄܹҶà¸ö¸¸ºìµã
 
        private uint[] AwardRecordList; //Áìȡ״̬
        public int roundNum { get; private set; } //µ±Ç°ÂִΠ´Ó1¿ªÊ¼
        public Dictionary<int, int> missionValueDict = new Dictionary<int, int>();  //ÀàÐÍ£ºÈÎÎñ½ø¶È
 
        public const int activityType = (int)OpenServerActivityCenter.ActivityType.AT_Activity2;
        public const int activityID = (int)NewDayActivityID.YunShiMissionAct;
        public static Operation operaType = Operation.default49;
 
        public int actNum = 12; //¶ÔÓ¦½çÃæ
        public event Action<bool> UpdateMissionEvent;
        public Dictionary<int, int> missionJumpIDs = new Dictionary<int, int>();
 
        public override void Init()
        {
            OperationTimeHepler.Instance.operationStartEvent += OperationStartEvent;
            OperationTimeHepler.Instance.operationEndEvent += OperationEndEvent;
            OperationTimeHepler.Instance.operationAdvanceEvent += OperationAdvanceEvent;
            OpenServerActivityCenter.Instance.Register(activityID, this, activityType);
 
            var json = JsonMapper.ToObject(FuncConfigConfig.Get("MissionAction").Numerical1);
            var keys = json.Keys.ToList();
            for (int i = 0; i < keys.Count; i++)
            {
                missionJumpIDs.Add(int.Parse(keys[i]), int.Parse(json[keys[i]].ToString()));
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            missionValueDict.Clear();
            roundNum = 0;
            AwardRecordList = new uint[0];
        }
 
        public void OnPlayerLoginOk()
        {
        }
 
        public override void UnInit()
        {
        }
 
        public bool IsOpen
        {
            get
            {
                return OperationTimeHepler.Instance.SatisfyOpenCondition(operaType);
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                return redPoint.state == RedPointState.Simple;
            }
        }
 
        public bool IsAdvance
        {
            get
            {
                return OperationTimeHepler.Instance.SatisfyAdvanceCondition(operaType);
            }
        }
 
        private void OperationEndEvent(Operation type, int state)
        {
            if (type == operaType)
            {
                if (onStateUpdate != null)
                {
                    onStateUpdate(activityID);
                }
                UpdateRedpoint();
                if (WindowCenter.Instance.IsOpen<YunShiWin>())
                {
                    WindowCenter.Instance.Close<YunShiWin>();
                }
            }
        }
 
        private void OperationAdvanceEvent(Operation type)
        {
            if (type == operaType)
            {
                if (onStateUpdate != null)
                {
                    onStateUpdate(activityID);
                }
            }
        }
 
        private void OperationStartEvent(Operation type, int state)
        {
            if (type == operaType && state == 0)
            {
                if (onStateUpdate != null)
                {
                    onStateUpdate(activityID);
                }
            }
        }
 
        // »ñÈ¡µ±Ç°Íê³ÉÈÎÎñµÄÊýÁ¿
        public int GetTaskOkCnt()
        {
            OperationMissionAct missionAct;
            OperationTimeHepler.Instance.TryGetOperation(operaType, out missionAct);
            if (missionAct == null)
                return 0; //·â°ü˳ÐòÈç¹ûÓÐÎÊÌâ ´Ë´¦Îª¿Õ
 
            int num = 0;
            var keys = missionAct.missionInfo.Keys.ToList();
            for (int i = 0; i < keys.Count; i++)
            {
                if (GetMissionAwardState(keys[i]) == 1 || GetMissionAwardState(keys[i]) == 2)
                    num += 1;
            }
            return num;
        }
 
        // »ñÈ¡µ±Ç°ÈÎÎñµÄ×ÜÊýÁ¿
        public int GetTaskAllCnt()
        {
            OperationMissionAct missionAct;
            OperationTimeHepler.Instance.TryGetOperation(operaType, out missionAct);
            return missionAct == null ? 0 : missionAct.missionInfo.Keys.Count;
        }
 
        //0 ²»¿ÉÁìÈ¡ 1 ¿ÉÁìÈ¡  2 ÒÑÁìÈ¡
        public int GetMissionAwardState(int id)
        {
            if (AwardRecordList.IsNullOrEmpty()) return 0;
            OperationMissionAct missionAct;
            OperationTimeHepler.Instance.TryGetOperation(operaType, out missionAct);
            if (missionAct == null) return 0;
 
            if (!missionAct.missionInfo.ContainsKey(id)) return 0;
 
            var mission = missionAct.missionInfo[id];
 
            if (!missionValueDict.ContainsKey(mission.TaskType)) return 0;
 
            if (missionValueDict[mission.TaskType] < mission.NeedValue)
            {
                return 0;
            }
 
            var listIndex = id / 31;
            var bitIndex = id % 31;
            if (listIndex >= AwardRecordList.Length)
            {
                //³¬¹ý·þÎñ¶ËÏ·¢µÄ³¤¶È ÈÏΪδÁìÈ¡
                return 1;
            }
 
            if (((int)Math.Pow(2, bitIndex) & (int)AwardRecordList[listIndex]) == 0)
            {
                return 1;
            }
            return 2;
        }
 
        private void UpdateRedpoint()
        {
            redPoint.state = RedPointState.None;
            if (!IsOpen) return;
            OperationMissionAct missionAct;
            OperationTimeHepler.Instance.TryGetOperation(operaType, out missionAct);
            if (missionAct == null) return; //·â°ü˳ÐòÈç¹ûÓÐÎÊÌâ ´Ë´¦Îª¿Õ
 
            var keys = missionAct.missionInfo.Keys.ToList();
            for (int i = 0; i < keys.Count; i++)
            {
                if (GetMissionAwardState(keys[i]) == 1)
                {
                    redPoint.state = RedPointState.Simple;
                    return;
                }
            }
        }
 
        public void UpdateMissionPlayerInfo(HAA73_tagMCActTaskPlayerInfo netPack)
        {
            if (netPack.ActNum != actNum)
                return;
            AwardRecordList = netPack.AwardRecordList;
            bool isNewRound = false;
            if (roundNum != netPack.RoundNum)
            {
                roundNum = netPack.RoundNum;
                isNewRound = true;
            }
            UpdateMissionEvent?.Invoke(isNewRound);
 
            UpdateRedpoint();
        }
 
        public void UpdateMissionPlayerValueInfo(HAA72_tagMCActTaskPlayerValueInfo netPack)
        {
            if (netPack.ActNum != actNum)
                return;
            for (int i = 0; i < netPack.TaskValueList.Length; i++)
            {
                missionValueDict[netPack.TaskValueList[i].TaskType] = (int)netPack.TaskValueList[i].TaskValue;
            }
 
            UpdateMissionEvent?.Invoke(false);
 
            UpdateRedpoint();
        }
 
        public void SendGetAward(int id)
        {
            CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
            getReward.RewardType = 71;
            getReward.DataEx = (uint)id;
            getReward.DataExStr = actNum.ToString();
            getReward.DataExStrLen = (byte)getReward.DataExStr.Length;
            GameNetSystem.Instance.SendInfo(getReward);
        }
    }
}