少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-18 72f94e2e0120db00113d0934d52151c436407c5a
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
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);
                    }
                }
            }
        }
 
        public event Action<int> bossSelectedEvent;
 
        List<int> sortedBossIds = new List<int>();
        Dictionary<int, DogzDungeonBossData> bosses = new Dictionary<int, DogzDungeonBossData>();
 
        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 GetLatestUnLockBoss()
        {
            var playerLevel = PlayerDatas.Instance.baseData.LV;
            for (int i = sortedBossIds.Count - 1; i >= 0; i--)
            {
                var bossId = sortedBossIds[i];
                var npcConfig = ConfigManager.Instance.GetTemplate<NPCConfig>(bossId);
                if (IsBossUnLocked(bossId) && findPreciousModel.IsBossAlive(bossId) && playerLevel >= npcConfig.NPCLV)
                {
                    return bossId;
                }
            }
 
            return sortedBossIds[0];
        }
 
        public bool IsBossUnLocked(int _bossId)
        {
            return bosses.ContainsKey(_bossId) && bosses[_bossId].isUnLocked;
        }
 
        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 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;
        }
    }
 
}