少年修仙传客户端代码仓库
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, November 15, 2018
//--------------------------------------------------------
//冰晶矿脉新
using System;
using System.Collections.Generic;
using vnxbqy.UI;
 
 
public class IceLodeStarAwardClass
    public int Index;
    public int Star;
    public int MinLv;
    public int MaxLv;
    public int ItemID;
    public int ItemCount;
    public int IsBind;
    public int Type;
 
}
public class IceCrystalVeinModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
{
    public Dictionary<int, IceLodeStarAwardClass> DicIceLodeStarAward = new Dictionary<int, IceLodeStarAwardClass>();
    public List<int> LineList = new List<int>();//玩法列表
    private List<IceLodeStarAwardClass> IceLodeStarAwardList = new List<IceLodeStarAwardClass>();
    public Dictionary<int, string> IconKeyDic = new Dictionary<int, string>();
    public int AwardRecord = 0;//领奖记录
    public int HasSweep = 0;//是否已扫荡
    public int DayLv = 0;//今日等级
    public int Cost = 0;//绑玉进入花费
    public int NeedVipLv = 0;//所需VIP等级
    public int SweepingNeedMoney = 0;//扫荡所需价格
    public bool IsIceCrystalVein_Copy = false;
    public bool IsIceCrystalVeinCopy = false;//是否再冰晶矿脉副本
    public event Action UpdateIceLodeInf;
    DungeonModel m_Model;
    DungeonModel model { get { return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<DungeonModel>()); } }
    public const int ICECRYSTALVEIN_MAPID = 31140;
 
    public override void Init()
    {
        var IceLodeCfg = FuncConfigConfig.Get("IceLodeCfg");
        Cost = int.Parse(IceLodeCfg.Numerical1);
        NeedVipLv = int.Parse(IceLodeCfg.Numerical5);
        SweepingNeedMoney= int.Parse(IceLodeCfg.Numerical3);
        var IceCrystalVeinIcon = FuncConfigConfig.Get("IceCrystalVeinIcon");
        IconKeyDic = ConfigParse.GetDic<int, string>(IceCrystalVeinIcon.Numerical1);
        Assignment();
    }
    public void OnBeforePlayerDataInitialize()
    {
        IsIceCrystalVein_Copy = false;
        IsIceCrystalVeinCopy = false;
        model.dungeonRecordChangeEvent -= dungeonRecordChangeEvent;
    }
 
    private void dungeonRecordChangeEvent(int fbId)
    {
    }
 
    public override void UnInit()
    {
 
    }
    public void OnPlayerLoginOk()
    {
        model.dungeonRecordChangeEvent += dungeonRecordChangeEvent;
        AddIceLodeStarAwardList();
    }
 
    private void Assignment()
    {
        if (DicIceLodeStarAward.Count <= 0)
        {
            var config = IceLodeStarAwardConfig.GetValues();
            foreach (var Value in config)
            {
                if (!DicIceLodeStarAward.ContainsKey(Value.id))
                {
                    IceLodeStarAwardClass iceLodeStar = new IceLodeStarAwardClass();
                    iceLodeStar.Index = Value.index;
                    iceLodeStar.Star = Value.Star;
                    var _jsonData = LitJson.JsonMapper.ToObject(Value.LV);
                    if (_jsonData.Count > 0)
                    {
                        iceLodeStar.MinLv = int.Parse(_jsonData[0].ToString());
                        iceLodeStar.MaxLv = int.Parse(_jsonData[1].ToString());
                    }
                    var jsonData = LitJson.JsonMapper.ToObject(Value.ItemList);
                    if (jsonData.Count > 0)
                    {
                        iceLodeStar.ItemID = int.Parse((jsonData[0][0]).ToString());
                        iceLodeStar.ItemCount = int.Parse((jsonData[0][1]).ToString());
                        iceLodeStar.IsBind = int.Parse((jsonData[0][2]).ToString());
                    }
                    iceLodeStar.Type = Value.Type;
                    DicIceLodeStarAward.Add(Value.id, iceLodeStar);
                }
            }
        }
 
 
    }
 
    public void IceLodeInfo(HB204_tagMCIceLodeInfo info)
    {
        if (info.Cnt > 0)
        {
            LineList.Clear();
            for (int i = 0; i < info.Cnt; i++)
            {
                LineList.Add(info.LineList[i]);
            }
        }
        AwardRecord = (int)info.AwardRecord;
        HasSweep = (int)info.HasSweep;
        DayLv = (int)info.DayLV;
        AddIceLodeStarAwardList();
        if (UpdateIceLodeInf != null)
        {
            UpdateIceLodeInf();
        }
    }
 
    public void SendGetAward(int Index)//领取奖励
    {
        CA504_tagCMPlayerGetReward getReward = new CA504_tagCMPlayerGetReward();
        getReward.RewardType = (byte)GotServerRewardType.Def_RewardType_IceLodeStar;
        getReward.DataEx = (uint)Index;
        getReward.DataExStrLen = 0;
        getReward.DataExStr = string.Empty;
        GameNetSystem.Instance.SendInfo(getReward);
    }
 
    public int GetAllStar()
    {
        int StarAll = 0;
        for (int i = 0; i < LineList.Count; i++)
        {
            DungeonRecord dungeonRecord;
            if (model.TryGetRecord(31140, out dungeonRecord))
            {
                if (dungeonRecord.lineGrades.ContainsKey(LineList[i]))
                {
                    StarAll += dungeonRecord.lineGrades[(LineList[i])];
                }
            }
        }
        return StarAll;
    }
    public bool IsFree(int Index)
    {
        DungeonRecord dungeonRecord;
        if (model.TryGetRecord(ICECRYSTALVEIN_MAPID, out dungeonRecord))
        {
            if (dungeonRecord.lineGrades.ContainsKey(Index))
            {
                int StarNumber = dungeonRecord.lineGrades[Index];
                if (StarNumber > 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
            }
            else
            {
                return true;
            }
        }
        return true;
    }
 
    private void AddIceLodeStarAwardList()
    {
        IceLodeStarAwardList.Clear();
        foreach (var key in DicIceLodeStarAward.Keys)
        {
            var Dic = DicIceLodeStarAward[key];
            int Lv = DayLv;
            if (Lv >= Dic.MinLv && Lv <= Dic.MaxLv)
            {
                IceLodeStarAwardList.Add(Dic);
            }
        }
    }
}