少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace vnxbqy.UI
{
    
    
    public class AllianceBossModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        List<int> m_BossIds = new List<int>();
        Dictionary<int, List<Item>> m_Items = new Dictionary<int, List<Item>>();
        Dictionary<int, AllianceBossLine> m_AllianceBossLines = new Dictionary<int, AllianceBossLine>();
 
        public const int DATAMAPID = 31260;
        public bool isActivityOver { get; private set; }
        public int participateLimit { get; private set; }
 
        public List<Item> inspireRewards { get; private set; }
 
        public int personalInspireCount { get; private set; }
 
        public readonly Redpoint redpoint = new Redpoint(218, 21802);
 
        public event Action allianceBossStateRefresh;
        public event Action allianceBossLineRefresh;
 
        DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
 
        public override void Init()
        {
            ParseConfig();
            DailyQuestActionTimer.Instance.RefreshDailyQuestState += RefreshDailyQuestState;
            PlayerDatas.Instance.fairyData.OnRefreshFairyMine += OnRefreshFairyMine;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            isActivityOver = false;
            m_AllianceBossLines.Clear();
        }
 
        public void OnPlayerLoginOk()
        {
            UpdateRedpoint();
        }
 
        public override void UnInit()
        {
            DailyQuestActionTimer.Instance.RefreshDailyQuestState -= RefreshDailyQuestState;
            PlayerDatas.Instance.fairyData.OnRefreshFairyMine -= OnRefreshFairyMine;
        }
 
        private void OnRefreshFairyMine()
        {
            UpdateRedpoint();
        }
 
        private void RefreshDailyQuestState()
        {
            UpdateRedpoint();
        }
 
        public int GetBossNpcId(int index)
        {
            return index < m_BossIds.Count ? m_BossIds[index] : 0;
        }
 
        public bool TryGetItems(int index, out List<Item> items)
        {
            return m_Items.TryGetValue(index, out items);
        }
 
        public bool TryGetBossLine(int index, out AllianceBossLine bossLine)
        {
            return m_AllianceBossLines.TryGetValue(index, out bossLine);
        }
 
        void ParseConfig()
        {
            var config = FuncConfigConfig.Get("LeagueBOSSNumber1");
            participateLimit = int.Parse(config.Numerical1);
 
            inspireRewards = new List<Item>();
            config = FuncConfigConfig.Get("LeagueBOSSReward1");
            var itemArray = LitJson.JsonMapper.ToObject<int[][]>(config.Numerical1);
            for (int i = 0; i < itemArray.Length; i++)
            {
                var item = itemArray[i];
                inspireRewards.Add(new Item()
                {
                    id = item[0],
                    count = item[1],
                });
            }
 
            personalInspireCount = int.Parse(config.Numerical2);
 
            config = FuncConfigConfig.Get("AllianceBoss");
            m_BossIds.AddRange(ConfigParse.GetMultipleStr<int>(config.Numerical1));
            m_Items.Add(0, new List<Item>());
            var itemsArray = ConfigParse.GetMultipleStr<int>(config.Numerical2);
            for (int i = 0; i < itemsArray.Length; i++)
            {
                m_Items[0].Add(new Item()
                {
                    id = itemsArray[i],
                    count = 1,
                });
            }
 
            m_Items.Add(1, new List<Item>());
            itemsArray = ConfigParse.GetMultipleStr<int>(config.Numerical3);
            for (int i = 0; i < itemsArray.Length; i++)
            {
                m_Items[1].Add(new Item()
                {
                    id = itemsArray[i],
                    count = 1,
                });
            }
        }
 
        public void ReceivePackage(HA40C_tagGCAllFamilyBossInfo package)
        {
            isActivityOver = package.IsEnd == 1;
            if (allianceBossStateRefresh != null)
            {
                allianceBossStateRefresh();
            }
 
            UpdateRedpoint();
        }
 
        public void ReceivePackage(HA007_tagGCFBLinePlayerCnt package)
        {
            if (package.MapID != DATAMAPID)
            {
                return;
            }
 
            m_AllianceBossLines.Clear();
 
            for (int i = 0; i < package.Count; i++)
            {
                var data = package.FBLineInfoList[i];
                m_AllianceBossLines[data.FBLineID] = new AllianceBossLine()
                {
                    playerCount = data.PlayerCnt,
                    hp = int.Parse(data.ExtraStr)
                };
            }
 
            if (allianceBossLineRefresh != null)
            {
                allianceBossLineRefresh();
            }
        }
 
        void UpdateRedpoint()
        {
            var redpointable = false;
            if (dailyQuestModel.GetQuestState((int)DailyQuestType.AllianceBoss) == DailyQuestModel.DailyQuestState.Normal)
            {
                if (!isActivityOver)
                {
                    redpointable = true;
                }
            }
            redpoint.state = redpointable ? RedPointState.Simple : RedPointState.None;
        }
 
        public struct AllianceBossLine
        {
            public int playerCount;
            public int hp;
        }
    }
}