少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, January 03, 2018
//--------------------------------------------------------
using LitJson;
using Spine;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
namespace vnxbqy.UI {
 
 
    //新挂机功能 离线在线都有收益
    public class OffLineOnHookModel : Model, IBeforePlayerDataInitialize
    {
        public MCTJGInfoClass mCTJGInfoClass = new MCTJGInfoClass(); //挂机累计收益
        public int startSeconds;    // 开始挂机时间戳
        public event Action onHookTimeEvent;
        public const int funcID = 228;
 
        public int quickHours; // 快速挂机时间-小时
        public int quickCostType;   // 快速挂机消耗货币类型
        public List<int> quickCostVaules = new List<int>();  // 快速挂机消耗货币数量, 随次数变化
        public string formuleExp;  //正常挂机经验公式
        Dictionary<int, int> maxOnHookTimeWithRealm = new Dictionary<int, int>();    // 通过境界等级获取最大挂机时间
        int orgMaxTime; //原始最大挂机时间
 
 
        public int openWinState; //上线打开界面 1为上线 2为有经验 状态为2打开界面
        public override void Init()
        {
            ParseConfig();
        }
 
        void ParseConfig()
        {
            var config = FuncConfigConfig.Get("GuajiQuick");
            quickHours = int.Parse(config.Numerical1);
            quickCostType = int.Parse(config.Numerical3);
            quickCostVaules = JsonMapper.ToObject<List<int>>(config.Numerical4);
 
            config = FuncConfigConfig.Get("GuajiAward");
            formuleExp = config.Numerical1;
 
            config = FuncConfigConfig.Get("GuajiTime");
            orgMaxTime = int.Parse(config.Numerical2);
            var json = JsonMapper.ToObject(config.Numerical3);
            var keys = json.Keys.ToList();
            for (int i = 0; i < keys.Count; i++)
            {
                var key = keys[i];
                maxOnHookTimeWithRealm[int.Parse(key)] = int.Parse(json[key].ToString());
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            mCTJGInfoClass = new MCTJGInfoClass();
            mCTJGInfoClass.moneys = new Dictionary<int, int>();
            mCTJGInfoClass.ItemList = new List<Int2>();
 
            openWinState = 1;
        }
 
        public override void UnInit()
        {
            
        }
 
        public void MCTJGInfo(HB109_tagMCGuajiInfo info)
        {
            mCTJGInfoClass.QuickAwardCount = info.QuickAwardCount;
            if (info.AwardType == 1)
            {
                string showStr = string.Empty;
                showStr += Language.Get("L2013", Language.Get("L2012"), info.Exp + (ulong)info.ExpPoint * 100000000) + "</r>";
                for (int i = 0; i < info.MoneyLen; i++)
                {
                    showStr += Language.Get("L2013", Language.Get("MoneyType_" + info.MoneyList[i].MoneyType), info.MoneyList[i].MoneyValue) + "</r>";
                }
 
                List<Item> itemList = new List<Item>();
                for (int i = 0; i < info.ItemLen; i++)
                {
                    itemList.Add(new Item((int)info.ItemList[i].ItemID, info.ItemList[i].Count));
                }
 
                ItemLogicUtility.Instance.ShowGetItemRichText(itemList, showStr, 8);
            }
            else
            {
 
                mCTJGInfoClass.AwardSeconds = (int)info.AwardSeconds;
                mCTJGInfoClass.Exp = (ulong)info.Exp + (ulong)info.ExpPoint * 100000000;
                mCTJGInfoClass.moneys = new Dictionary<int, int>();
                for (int i = 0; i < info.MoneyLen; i++)
                {
                    mCTJGInfoClass.moneys[info.MoneyList[i].MoneyType] = (int)info.MoneyList[i].MoneyValue;
                }
 
                mCTJGInfoClass.ItemList = new List<Int2>();
                for (int i = 0; i < info.ItemLen; i++)
                {
                    Int2 item = new Int2();
                    item.x = (int)info.ItemList[i].ItemID;
                    item.y = (int)info.ItemList[i].Count;
                    mCTJGInfoClass.ItemList.Add(item);
                }
                startSeconds = TimeUtility.AllSeconds;
                if (openWinState == 1)
                {
                    //累计时间低于120秒不弹界面
                    if (info.AwardSeconds > 120)
                        openWinState = 2;
                    else
                        openWinState = 0;
                }
                UpdateRedPoint();
            }
            onHookTimeEvent?.Invoke();
        }
 
        public int GetMaxQuickCount()
        {
            return VipPrivilegeConfig.GetVipPrivilegeData(47, PlayerDatas.Instance.baseData.VIPLv);
        }
 
        public int GetQuickCost()
        {
            int index = mCTJGInfoClass.QuickAwardCount;
            if (index >= quickCostVaules.Count)
            {
                index = quickCostVaules.Count - 1;
            }
            return quickCostVaules[index];
        }
 
 
        // 是否领取快速收益,是发1
        public void GetAward(int type)
        {
            var pack = new CA504_tagCMPlayerGetReward();
            pack.RewardType = 73;
            pack.DataEx = (uint)type;
            GameNetSystem.Instance.SendInfo(pack);
        }
 
        // 获取境界对应的最大挂机时间 {10:2, 15:5, 20:8, 25:12, 30:15} 取接近的最小境界
        public int GetMaxOnHookTimeWithRealm()
        {
            int realm = PlayerDatas.Instance.baseData.realmLevel;
            int maxTime = 0;
            var keys = maxOnHookTimeWithRealm.Keys.ToList();
            keys.Sort();
            for (int i = 0; i < keys.Count; i++)
            {
                if (realm >= keys[i])
                {
                    maxTime = maxOnHookTimeWithRealm[keys[i]];
                }
            }
            return (maxTime + orgMaxTime);
        }
 
        // 获取哪个境界提升了最大挂机时间
        public int GetAddMaxOnHookTime(int realm)
        {
            if (maxOnHookTimeWithRealm.ContainsKey(realm))
                return maxOnHookTimeWithRealm[realm];
            return 0;
        }
 
        Redpoint redpoint = new Redpoint(MainRedDot.OnHookRedpoint);
 
        //红点提醒 大于10-60分钟, 上线为主动弹界面PopupWindowsProcessor
        public void UpdateRedPoint()
        {
            redpoint.state = RedPointState.None;
            if (!FuncOpen.Instance.IsFuncOpen(funcID))
                return;
 
            if (mCTJGInfoClass.AwardSeconds > 120 + PlayerDatas.Instance.baseData.LV * 5)
            {
                redpoint.state = RedPointState.Simple;
            }
        }
    }
 
 
    public class MCTJGInfoClass
    {
        public byte QuickAwardCount;    // 今日已快速挂机收益次数
        public int AwardSeconds;    // 已累计收益时长,秒
        public ulong Exp;
        public Dictionary<int, int> moneys;    // 已累计货币
        public List<Int2> ItemList;    // 已累计物品
    }
 
}