少年修仙传客户端代码仓库
client_Wu Xijin
2019-03-14 007541eae116f6b73f992c1a4df7ecbe77178099
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
using LitJson;
using Snxxz.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
using UnityEngine;
namespace Snxxz.UI
{
    public class RealmModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize
    {
        Dictionary<int, Dictionary<int, int>> m_RealmProperties = new Dictionary<int, Dictionary<int, int>>();
        Dictionary<int, Dictionary<int, int[]>> m_RealmPreviewEquips = new Dictionary<int, Dictionary<int, int[]>>();
        List<List<int>> m_RealmStages = new List<List<int>>();
        public int realmMaxLevel { get; private set; }
        public bool isBossPass { get; private set; }
 
        public const int REALM_DUNGEON_ID = 31110;
 
        public readonly Redpoint levelUpRedpoint = new Redpoint(114, 11401);
        public readonly Redpoint challengeRedpoint = new Redpoint(114, 11402);
 
        int m_SelectRealm = 0;
        public int selectRealm
        {
            get { return m_SelectRealm; }
            set
            {
                if (m_SelectRealm != value)
                {
                    m_SelectRealm = value;
                    if (selectRealmRefresh != null)
                    {
                        selectRealmRefresh();
                    }
                }
            }
        }
 
        public event Action selectRealmRefresh;
 
        EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
 
        public override void Init()
        {
            ParseConfig();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            isBossPass = false;
        }
 
        public void OnPlayerLoginOk()
        {
        }
 
        public override void UnInit()
        {
        }
 
        void ParseConfig()
        {
            realmMaxLevel = 0;
            List<int> stages = new List<int>();
            m_RealmStages.Add(stages);
            var configs = RealmConfig.GetValues();
            foreach (var config in configs)
            {
                if (config.Lv > realmMaxLevel)
                {
                    realmMaxLevel = config.Lv;
                }
 
                if (config.AddAttrType != null && config.AddAttrType.Length > 0)
                {
                    Dictionary<int, int> dict = new Dictionary<int, int>();
                    for (int i = 0; i < config.AddAttrType.Length; i++)
                    {
                        dict.Add(config.AddAttrType[i], config.AddAttrNum[i]);
                    }
                    m_RealmProperties.Add(config.Lv, dict);
                }
 
                if (stages.Contains(config.Lv))
                {
                    stages = new List<int>();
                    m_RealmStages.Add(stages);
                }
 
                stages.Add(config.Lv);
 
                if (config.BossID != 0)
                {
                    var nextConfig = RealmConfig.Get(config.Lv + 1);
                    if (nextConfig != null)
                    {
                        stages.Add(config.Lv + 1);
                    }
                }
 
                if (!string.IsNullOrEmpty(config.equips))
                {
                    var json = LitJson.JsonMapper.ToObject(config.equips);
                    Dictionary<int, int[]> dict = new Dictionary<int, int[]>();
                    foreach (var jobKey in json.Keys)
                    {
                        var job = int.Parse(jobKey);
                        var equipArray = LitJson.JsonMapper.ToObject<int[]>(json[jobKey].ToJson());
                        dict.Add(job, equipArray);
                    }
                    m_RealmPreviewEquips.Add(config.Lv, dict);
                }
            }
        }
 
        public bool TryGetRealmProperty(int level, out Dictionary<int, int> propertyDict)
        {
            return m_RealmProperties.TryGetValue(level, out propertyDict);
        }
 
        public bool TryGetRealmStages(int index, out List<int> stages)
        {
            stages = null;
            if (index < m_RealmStages.Count)
            {
                stages = m_RealmStages[index];
                return true;
            }
            return false;
        }
 
        public bool TryGetRealmPreviewEquips(int level, int job, out int[] equips)
        {
            equips = null;
            if (m_RealmPreviewEquips.ContainsKey(level))
            {
                return m_RealmPreviewEquips[level].TryGetValue(job, out equips);
            }
            return false;
        }
 
        public bool IsUnlockEquipRealm(int realmLevel, out int level)
        {
            level = 0;
            var equipSets = equipModel.GetAllEquipSets();
            var index = equipSets.FindIndex((x) =>
            {
                var equipSet = equipModel.GetEquipSet(x);
                if (equipSet != null)
                {
                    return equipSet.realm == realmLevel;
                }
                return false;
            });
            if (index != -1)
            {
                level = equipSets[index];
                return true;
            }
            return false;
        }
 
        public int GetRealmStage(int realmLevel)
        {
            for (int i = 0; i < m_RealmStages.Count; i++)
            {
                var stages = m_RealmStages[i];
                if (stages.Contains(realmLevel))
                {
                    return i;
                }
            }
            return m_RealmStages.Count - 1;
        }
 
        public void SendLevelUpRealm()
        {
            CA523_tagCMRealmLVUp pak = new CA523_tagCMRealmLVUp();
            GameNetSystem.Instance.SendInfo(pak);
        }
 
        public void ReceivePackage(HA311_tagMCSyncRealmInfo package)
        {
            isBossPass = package.IsPass == 1;
        }
    }
}