少年修仙传客户端代码仓库
hch
3 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
 
class BossHomeBuyTimesWin : ILWindow
{
 
    RectTransform noneVipContainer;
    Text noneVipTip;
    Button viewVipButton;
    Text vipLevel;
    RectTransform normalVipContainer;
    Text todayBuyTimesText;
    Text priceText;
    Text nextTip;
    Button buyButton;
    Button rechargeButton;
    Text maxPrivilegeText;
    Button closeButton;
 
    int killTimePrice;
 
    BossHomeModel bossHomeModel;
    VipModel vipModel;
 
    protected override void BindController()
    {
        base.BindController();
        bossHomeModel = ModelCenter.Instance.GetModelEx<BossHomeModel>();
        vipModel = ModelCenter.Instance.GetModelEx<VipModel>();
 
        noneVipContainer = proxy.GetWidgtEx<RectTransform>("noneVipContainer");
        noneVipTip = proxy.GetWidgtEx<Text>("noneVipTip");
        viewVipButton = proxy.GetWidgtEx<Button>("viewVipButton");
        vipLevel = proxy.GetWidgtEx<Text>("vipLevel");
        normalVipContainer = proxy.GetWidgtEx<RectTransform>("normalVipContainer");
        todayBuyTimesText = proxy.GetWidgtEx<Text>("todayBuyTimesText");
        priceText = proxy.GetWidgtEx<Text>("priceText");
        nextTip = proxy.GetWidgtEx<Text>("nextTip");
        buyButton = proxy.GetWidgtEx<Button>("buyButton");
        rechargeButton = proxy.GetWidgtEx<Button>("rechargeButton");
        maxPrivilegeText = proxy.GetWidgtEx<Text>("maxPrivilegeText");
        closeButton = proxy.GetWidgtEx<Button>("closeButton");
 
        var content = FuncConfigConfig.Get("KillBossCntLimit1").Numerical2;
 
        Int2 int2;
        if (Int2.TryParse(content, out int2))
            this.killTimePrice = int2.y;
    }
 
    protected override void AddListeners()
    {
        base.AddListeners();
        this.viewVipButton.AddListener(() =>
        {
            WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
            WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeVip4);
        });
        this.buyButton.AddListener(() =>
        {
            BuyTimes();
        });
        this.rechargeButton.AddListener(() =>
        {
            WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
            WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.VipRechargeFunc1);
        });
        this.closeButton.SetListener(() =>
        {
            WindowCenter.Instance.CloseIL<BossHomeBuyTimesWin>();
        });
    }
 
    protected override void OnPreOpen()
    {
        base.OnPreOpen();
        Display();
        bossHomeModel.boughtTimeChangeEvent += Display;
    }
 
    protected override void OnPreClose()
    {
        base.OnPreClose();
        bossHomeModel.boughtTimeChangeEvent -= Display;
    }
 
    void Display()
    {
        var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
        var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, vipLevel);
        if (privilege > 0)
            DisplayNormalVip();
        else
            DisplayNoneVip();
    }
 
    void DisplayNormalVip()
    {
        this.noneVipContainer.SetActiveIL(false);
        this.normalVipContainer.SetActiveIL(true);
        var vipLevel = PlayerDatas.Instance.baseData.VIPLv;
        var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, vipLevel);
        var absolutelyPrivilege = VipPrivilegeConfig.GetVipPrivilegeData(37, 15);
        var boughtTimes = this.bossHomeModel.boughtTimes;
 
        this.priceText.text = Language.Get("TimesBuyLanguage3", this.killTimePrice);
        string description = "";
        if (boughtTimes >= privilege)
            description = UIHelper.AppendColor(TextColType.Red, (privilege - boughtTimes).ToString(), true);
        else
            description = UIHelper.AppendColor(TextColType.Green, (privilege - boughtTimes).ToString(), true);
 
        this.todayBuyTimesText.text = Language.Get("TimesBuyLanguage1", description, privilege);
        this.nextTip.SetActiveIL(privilege < absolutelyPrivilege);
 
        if (privilege < absolutelyPrivilege)
        {
            var nextVipLevel = 0;
            var timesDif = 0;
            for (int i = 1; i <= VipPrivilegeConfig.MAX_VIP_LEVEL; i++)
            {
                var tempTime = VipPrivilegeConfig.GetVipPrivilegeData(37, i);
                if (tempTime > privilege)
                {
                    nextVipLevel = i;
                    timesDif = tempTime - privilege;
                    break;
                }
            }
            this.nextTip.text = Language.Get("TimesBuyLanguage2", nextVipLevel, timesDif);
        }
 
        this.buyButton.SetActiveIL(boughtTimes < privilege);
        this.maxPrivilegeText.SetActiveIL(privilege >= absolutelyPrivilege && boughtTimes >= privilege);
        this.rechargeButton.SetActiveIL(privilege < absolutelyPrivilege && boughtTimes >= privilege);
    }
 
 
    void DisplayNoneVip()
    {
        this.noneVipContainer.SetActiveIL(true);
        this.normalVipContainer.SetActiveIL(false);
        var vipLevel = 0;
        var buyTimes = 0;
        for (int i = 1; i <= VipPrivilegeConfig.MAX_VIP_LEVEL; i++)
        {
            var privilege = VipPrivilegeConfig.GetVipPrivilegeData(37, i);
            if (privilege > 0)
            {
                vipLevel = i;
                buyTimes = privilege;
                break;
            }
        }
 
        this.vipLevel.text = vipLevel.ToString();
        var rechargeCount = vipModel.GetVipPreExp(vipLevel) - this.vipModel.vipTotalExp;
        this.noneVipTip.text = Language.Get("BossHomeLack1", rechargeCount, vipLevel, buyTimes);
    }
 
 
    void BuyTimes()
    {
        var myDiamond = PlayerDatas.Instance.baseData.diamond;
        var remindTimes = this.bossHomeModel.remindTimes;
        var timesLimit = this.vipModel.GetVipPrivilegeCnt(VipPrivilegeType.BossHomeAwardLimit);
        if (remindTimes >= timesLimit)
            SysNotifyMgr.Instance.ShowTip("BossHomeBuyLimit");
        else if (myDiamond < this.killTimePrice)
            WindowCenter.Instance.OpenEx<RechargeTipWin>();
        else
        {
            var data = new CA50A_tagCMBuyKillBossCnt();
            data.KillBossMark = 1;
            GameNetSystem.Instance.SendInfo(data);
        }
    }
 
}