少年修仙传客户端代码仓库
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
using vnxbqy.UI;
using System;
 
using LitJson;
using UnityEngine;
using System.Collections.Generic;
 
 
    public class TaiChiModel : Model,IBeforePlayerDataInitialize
{
    //日常活动
    DailyQuestModel _dailyQuestModel;
    public DailyQuestModel dailyQuestModel
    {
        get { return _dailyQuestModel ?? (_dailyQuestModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
    }
 
    public readonly int TaiChiDailyTaskID = 12;
 
    private FuncConfigConfig diceFreeNumFunc;
    private FuncConfigConfig diceRewardFunc;
    private DailyQuestOpenTimeConfig dailyTask;
    public int sumFreeNum { get; private set; }
    public int sumPlayNum { get; private set; }
 
    private Dictionary<int, DiceReward> diceRewardDict = new Dictionary<int, DiceReward>();
 
    public override void Init()
    {
        diceRewardDict.Clear();
        diceFreeNumFunc = FuncConfigConfig.Get("DiceFreeNum");
        sumFreeNum = int.Parse(diceFreeNumFunc.Numerical1);
        diceRewardFunc = FuncConfigConfig.Get("DiceReward");
        dailyTask = DailyQuestOpenTimeConfig.Get(7);
        sumPlayNum = dailyTask.DayTimes;
        JsonData jsonData = JsonMapper.ToObject(diceRewardFunc.Numerical1);
        foreach(var key in jsonData.Keys)
        {
            DiceReward diceReward = new DiceReward(int.Parse(key));
            diceRewardDict.Add(diceReward.taiChiNum,diceReward);
            foreach (var key1 in jsonData[key].Keys)
            {
                switch (key1)
                {
                    case "exp":
                        diceReward.SetExpModel(jsonData[key][key1].ToString(),2103);
                        break;
                    case "gold":
                        diceReward.SetGoldModel((int)jsonData[key][key1],2100);
                        break;
                    case "item":
                        if(jsonData[key][key1].IsArray)
                        {
                            if(jsonData[key][key1].Count >= 2)
                            {
                                diceReward.SetItemModel((int)jsonData[key][key1][0], (int)jsonData[key][key1][1]);
                            }
                        }
                        break;
                }
            } 
        }
        DailyQuestActionTimer.Instance.RefreshDailyQuestState += RefreshDailyQuestState;
    }
 
    public void OnBeforePlayerDataInitialize()
    {
        diceType = -1;
        useFreeCnt = 0;
        taiChiNum = 0;
        taiChiResultNum = "0";
    }
 
    public override void UnInit()
    {
        DailyQuestActionTimer.Instance.RefreshDailyQuestState -= RefreshDailyQuestState;
    }
 
 
    private void RefreshDailyQuestState()
    {
        var state = dailyQuestModel.GetQuestState(TaiChiDailyTaskID);
        if (state == DailyQuestModel.DailyQuestState.Normal) return;
 
        WindowCenter.Instance.Close<WytjGameWin>();
        WindowCenter.Instance.Close<WytjRulesWin>();
    }
 
    public string taiChiResultNum { get; private set; }
    public int diceType { get; private set; }
    public int useFreeCnt { get; private set; }
    public int taiChiNum { get; private set; }
    public List<int> resultNumlist = new List<int>();
    public event Action RefreshTaiChiModel;
    public void SetTaiChiModel(HAB22_tagMCDiceExResult result)
    {
        taiChiResultNum = result.ResultNum.ToString();
        diceType = result.DiceType;
        useFreeCnt = result.UseFreeCnt;
        taiChiNum = 0;
        resultNumlist.Clear();
        for (int i = 0; i <taiChiResultNum.Length; i++)
        {
            int point = int.Parse(taiChiResultNum.Substring(i,1));
            resultNumlist.Add(point);
            if(point == 6)
            {
                taiChiNum += 1;
            }
        }
 
        if(RefreshTaiChiModel != null)
        {
            RefreshTaiChiModel();
        }
        //ModelCenter.Instance.GetModel<DungeonModel>().GetDungeonTotalTimes();
        //ModelCenter.Instance.GetModel<DungeonModel>().GetDungeonEnterTimes();
        //ModelCenter.Instance.GetModel<DailyQuestModel>().TryGetOpenTime();
    }
 
    public event Action GetResultEvent;
    public int getResultNum { get; private set; }
    public void GetTaichiResult(int taichiNum)
    {
        getResultNum = taichiNum;
        if(GetResultEvent != null)
        {
            GetResultEvent();
        }
    }
 
    public void SendQuest(int type)
    {
        CAB0C_tagCMDiceEx tagCMDiceEx = new CAB0C_tagCMDiceEx();
        tagCMDiceEx.Type = (byte)type;
        GameNetSystem.Instance.SendInfo(tagCMDiceEx);
    }
 
    public DiceReward GetDiceReward(int taiChiNum)
    {
        DiceReward diceReward = null;
        diceRewardDict.TryGetValue(taiChiNum, out diceReward);
        return diceReward;
    }
 
    public long GetDiceRewardExp(string exp)
    {
        Equation.Instance.Clear();
        PlayerLVConfig playerLVConfig = PlayerLVConfig.Get(PlayerDatas.Instance.baseData.LV);
        int reExp = 0;
        if(playerLVConfig != null)
        {
            reExp = playerLVConfig.ReExp;
        }
        Equation.Instance.AddKeyValue("reExp",reExp);
        return Equation.Instance.Eval<long>(exp);
    }
 
    public bool CheckEnterError(out int error)
    {
        int playerLv = PlayerDatas.Instance.baseData.LV;
        var config = DailyQuestConfig.Get(TaiChiDailyTaskID);
        FuncOpenLVConfig openLVConfig = FuncOpenLVConfig.Get(config.UnLockFuncID);
        int limitLv = openLVConfig.LimitLV;
        var completedTimes = dailyQuestModel.GetDailyQuestCompletedTimes(TaiChiDailyTaskID);
        var totalTimes = dailyQuestModel.GetDailyQuestTotalTimes(TaiChiDailyTaskID);
        error = 0;
        if (playerLv < limitLv)
        {
            error = 1;
            return true;
        }
        else if(completedTimes >= totalTimes)
        {
            error = 2;
            return true;
        }
 
        return false;
    }
}
 
public class DiceReward
{
    public int taiChiNum { get; private set; }
    public int expId { get; private set; }
    public string exp { get; private set; }
    public int goldId { get; private set; }
    public int gold { get; private set; }
    public int itemID { get; private set; }
    public int itemCount { get; private set; }
    public ItemConfig itemConfig { get; private set; }
    public DiceReward(int taiChiNum)
    {
        this.taiChiNum = taiChiNum;
    }
 
    public void SetExpModel(string exp,int expId)
    {
        this.exp = exp;
        this.expId = expId;
    }
 
    public void SetGoldModel(int gold,int goldId)
    {
        this.gold = gold;
        this.goldId = goldId;
    }
 
    public void SetItemModel(int itemId, int itemCount)
    {
        this.itemID = itemId;
        this.itemCount = itemCount;
        itemConfig = ItemConfig.Get(itemId);
    }
}