少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-20 29ec69943cde9711787603a29f8b6327c726de94
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TableConfig;
using System;
 
namespace Snxxz.UI
{
    public class DogzDungeonModel : Model
    {
 
        public const int DOGZDUNGEON_REDPOINT = 76009;
        public const int DATA_MAPID = 1010010;
 
        int m_SelectedBoss = 0;
        public int selectedBoss {
            get {
                return this.m_SelectedBoss;
            }
            set {
                if (this.m_SelectedBoss != value)
                {
                    this.m_SelectedBoss = value;
                    if (bossSelectedEvent != null)
                    {
                        bossSelectedEvent(value);
                    }
                }
            }
        }
 
        int m_WearyValue = 0;
        public int wearyValue {
            get { return m_WearyValue; }
            set {
                if (m_WearyValue != value)
                {
                    m_WearyValue = value;
                    if (bossWearyValueChangeEvent != null)
                    {
                        bossWearyValueChangeEvent();
                    }
                }
            }
        }
 
        int m_BigBoxCollectCount = 0;
        public int bigBoxCollectCount {
            get { return m_BigBoxCollectCount; }
            set {
                if (m_BigBoxCollectCount != value)
                {
                    m_BigBoxCollectCount = value;
                    if (bigBoxCollectCountChangeEvent != null)
                    {
                        bigBoxCollectCountChangeEvent();
                    }
                }
            }
        }
 
        public event Action<int> bossSelectedEvent;
        public event Action bossWearyValueChangeEvent;
        public event Action bigBoxCollectCountChangeEvent;
        public event Action boxSurplusChangeEvent;
        public event Action eliteSurplusChangeEvent;
 
        List<int> sortedBossIds = new List<int>();
        Dictionary<int, DogzDungeonBossData> bosses = new Dictionary<int, DogzDungeonBossData>();
        public DogzDungeonBox dogzDungeonBox = new DogzDungeonBox();
        public DogzDungeonGuard dogzDungeonGuard = new DogzDungeonGuard();
        Redpoint redpoint = new Redpoint(DOGZDUNGEON_REDPOINT);
 
        FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
 
        public override void Init()
        {
        }
 
        public override void UnInit()
        {
        }
 
        public bool TryGetBossData(int _bossId, out DogzDungeonBossData _data)
        {
            return bosses.TryGetValue(_bossId, out _data);
        }
 
        public List<int> GetBosses()
        {
            return new List<int>(bosses.Keys);
        }
 
        public int GetRecommendBoss()
        {
            if (bigBoxCollectCount < 2) //未疲劳
            {
                return 999;//大宝箱npc id
            }
 
            if (wearyValue < GeneralConfig.Instance.bossWearyValues[1])
            {
                var playerLevel = PlayerDatas.Instance.baseData.LV;
                for (int i = sortedBossIds.Count - 1; i >= 0; i--)
                {
                    var bossId = sortedBossIds[i];
                    var dogzConfig = ConfigManager.Instance.GetTemplate<DogzDungeonConfig>(bossId);
                    if (dogzConfig.MonsterType == 3 || dogzConfig.MonsterType == 4)
                    {
                        var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(bossId);
                        if (IsBossUnLocked(bossId) && findPreciousModel.IsBossAlive(bossId) && playerLevel >= npcConfig.NPCLV)
                        {
                            return bossId;
                        }
                    }
                }
 
                return sortedBossIds[0];
            }
 
            return 999;//大宝箱 npcid
        }
 
        public bool IsBossUnLocked(int _bossId)
        {
            return bosses.ContainsKey(_bossId) && bosses[_bossId].isUnLocked;
        }
 
        public void UpdateBoxSurplusInfo()
        {
 
            if (boxSurplusChangeEvent != null)
            {
                boxSurplusChangeEvent();
            }
        }
 
        public void UpdateEliteSurplusInfo()
        {
            if (eliteSurplusChangeEvent != null)
            {
                eliteSurplusChangeEvent();
            }
        }
 
        private void ParseConfig()
        {
            var configs = ConfigManager.Instance.GetAllValues<DogzDungeonConfig>();
            foreach (var config in configs)
            {
                bosses[config.NPCID] = new DogzDungeonBossData(config.NPCID);
                sortedBossIds.Add(config.NPCID);
            }
 
            sortedBossIds.Sort(DogzDungeonBossData.LevelCompare);
        }
    }
 
    public class DogzDungeonBox
    {
        public int bigBoxSurplus;
        public int smallBoxSurplus;
 
        public void UpdateBoxInfo(int _big, int _small)
        {
            bigBoxSurplus = _big;
            smallBoxSurplus = _small;
        }
    }
 
    public class DogzDungeonGuard
    {
        public int guardSurplus;
 
        public void UpdateGuardInfo(int _surplus)
        {
            guardSurplus = _surplus;
        }
    }
 
    public class DogzDungeonBossData
    {
        public int id { get; private set; }
        public bool isUnLocked {
            get {
                var config = ConfigManager.Instance.GetTemplate<NPCConfig>(id);
                return PlayerDatas.Instance.baseData.LV >= config.NPCLV;
            }
        }
 
        public DogzDungeonBossData(int _id)
        {
            this.id = _id;
        }
 
        public static int LevelCompare(int a, int b)
        {
            var configA = ConfigManager.Instance.GetTemplate<NPCConfig>(a);
            var configB = ConfigManager.Instance.GetTemplate<NPCConfig>(b);
 
            return configA.NPCLV < configB.NPCLV ? -1 : 1;
        }
    }
 
}