少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
 
using System.Text;
using System.Collections.Generic;
using LitJson;
using System;
using UnityEngine;
 
namespace vnxbqy.UI
{
    
    public class TreasureEffectModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
    {
        public List<int> treasureAddAtklist { get; private set; }
        public List<string> treasureIdlist { get; private set; }
        public Dictionary<int, Dictionary<int, int>> treasureSignDict { get; private set; }
        TreasureModel m_Model;
        TreasureModel model {
            get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TreasureModel>()); }
        }
 
        SignInModel signInModel { get { return ModelCenter.Instance.GetModel<SignInModel>(); } }
 
        public override void Init()
        {
            FuncConfigConfig addExp = FuncConfigConfig.Get("VIPAddAtkEXP");
            int[] addExpIds = ConfigParse.GetMultipleStr<int>(addExp.Numerical2);
            treasureAddAtklist = new List<int>();
            for (int i = 0; i < addExpIds.Length; i++)
            {
                treasureAddAtklist.Add(addExpIds[i]);
            }
 
            FuncConfigConfig MWSignDayAttr = FuncConfigConfig.Get("MWSignDayAttr");
            int treasureId = int.Parse(MWSignDayAttr.Numerical2);
            JsonData signAttrData = JsonMapper.ToObject(MWSignDayAttr.Numerical1);
            treasureSignDict = new Dictionary<int, Dictionary<int, int>>();
            Dictionary<int, int> attrDict = new Dictionary<int, int>();
            treasureSignDict.Add(treasureId, attrDict);
            foreach (var id in signAttrData.Keys)
            {
                attrDict.Add(int.Parse(id), int.Parse(signAttrData[id].ToString()));
            }
 
            treasureIdlist = TreasureConfig.GetKeys();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            treasureId = 0;
            vipLv = 0;
            showType = 0;
            killNpcAtk = 0;
            effectDesSB.Length = 0;
        }
 
        public void OnAfterPlayerDataInitialize()
        {
 
        }
 
        public void OnPlayerLoginOk()
        {
 
        }
 
        public override void UnInit()
        {
 
        }
        public bool CheckIsTreasure(int id)
        {
            if (treasureIdlist.Contains(id.ToString()))
            {
                return true;
            }
 
            return false;
        }
 
        public int treasureId { get; private set; }
        public int vipLv { get; private set; }
        public StringBuilder effectDesSB = new StringBuilder();
        public int killNpcAtk { get; private set; }
        public int showType;
 
        public void SetTreasureID(int id, int vipLv = 0)
        {
            this.treasureId = id;
            this.vipLv = vipLv;
            SetTreasureEffectDes(out showType);
            if (!WindowCenter.Instance.IsOpen<TreasureEffectWin>())
            {
                WindowCenter.Instance.Open<TreasureEffectWin>();
            }
        }
 
        /// <summary>
        /// type 1 Vip杀怪等级 2 每日签到 3 获得经验
        /// </summary>
        /// <param name="type"></param>
        public void SetTreasureEffectDes(out int type)
        {
            type = 0;
            effectDesSB.Length = 0;
            killNpcAtk = 0;
            TreasureConfig treasureConfig = TreasureConfig.Get(treasureId);
            if (treasureAddAtklist.Contains(treasureId))
            {
                type = 1;
                var killConfig = VIPKillNPCConfig.Get(Mathf.Max(model.vipKillNPCTreasure.level, 1));
                if (killConfig != null)
                {
                    killNpcAtk = killConfig.MaxAtk;
                }
                string des = treasureConfig.Verse[0].Replace("{0}", killNpcAtk.ToString());
                effectDesSB.Append(des);
                return;
            }
 
            if (treasureSignDict.ContainsKey(treasureId))
            {
                Dictionary<int, int> attrDict = treasureSignDict[treasureId];
                Treasure treasure;
                model.TryGetTreasure(treasureId, out treasure);
                bool isHaveTreasure = false;
                if (treasure != null)
                {
                    if (treasure.state == TreasureState.Collected)
                    {
                        isHaveTreasure = true;
                    }
                }
                foreach (var id in attrDict.Keys)
                {
                    PlayerPropertyConfig propertyConfig = PlayerPropertyConfig.Get(id);
                    string des = string.Format(treasureConfig.Verse[0], PlayerPropertyConfig.GetValueDescription(id, attrDict[id]), propertyConfig.Name);
                    effectDesSB.Append(des);
                    if (signInModel.totalSignInCount > 0)
                    {
                        des = string.Format(treasureConfig.Verse[1], signInModel.totalSignInCount);
                        effectDesSB.Append(StringUtility.Contact("\n", des));
                        int addAtk = signInModel.totalSignInCount * attrDict[id];
                        if (isHaveTreasure)
                        {
                            des = string.Format(treasureConfig.Verse[2], Language.Get("TreasureEffect105", PlayerPropertyConfig.GetValueDescription(id, addAtk)));
                        }
                        else
                        {
                            des = string.Format(treasureConfig.Verse[2], Language.Get("TreasureEffect104", PlayerPropertyConfig.GetValueDescription(id, addAtk)));
                        }
                        effectDesSB.Append(StringUtility.Contact("\n", des));
                    }
                }
                return;
            }
 
            if (effectDesSB.Length <= 0)
            {
                type = 3;
                effectDesSB.Append(treasureConfig.Verse[0]);
            }
 
        }
 
        Dictionary<int, int> atkDict = new Dictionary<int, int>();
        public int GetTreasureFight()
        {
            int fight = model.GetTreasureFightPower(treasureId);
            switch (showType)
            {
                case 1:
                    var killConfig = VIPKillNPCConfig.Get(1);
                    if (killConfig != null)
                    {
                        atkDict.Clear();
                        atkDict.Add(67, killConfig.MinAtk);
                        atkDict.Add(68, killConfig.MaxAtk);
                        fight += UIHelper.GetFightPower(atkDict);
                    }
                    break;
                case 2:
                    fight += UIHelper.GetFightPower(treasureSignDict[treasureId]);
                    break;
                case 3:
                    break;
                default:
                    break;
            }
 
            return fight;
        }
 
        public int GetFightPower(int _treasureId, int _type, int _value)
        {
            Treasure _treasure;
            model.TryGetTreasure(_treasureId, out _treasure);
            var _fight = model.GetTreasureFightPower(_treasureId);
            switch (_type)
            {
                case 1:
                    var killConfig = VIPKillNPCConfig.Get(Mathf.Max(_value, 1));
                    if (killConfig != null)
                    {
                        var _propertyDict = new Dictionary<int, int>();
                        _propertyDict.Add(67, killConfig.MinAtk);
                        _propertyDict.Add(68, killConfig.MaxAtk);
                        _fight += UIHelper.GetFightPower(_propertyDict);
                    }
                    break;
                case 2:
                    if (_treasure.treasureStages[0].unlockType == TreasureStageUnlock.Property)
                    {
                        _fight += UIHelper.GetFightPower(_treasure.treasureStages[0].propertyDict);
                    }
                    break;
            }
            return _fight;
        }
    }
}