少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, June 11, 2019
//--------------------------------------------------------
 
using UnityEngine.UI;
using System.Collections.Generic;
using vnxbqy.UI;
 
public class LuckyCloudBuyWin : ILWindow
{
    Button m_Close;
    ItemCell bigItemCell;
    Text bigPrice;
    List<Image> moneyTypes = new List<Image>();
    ScrollerController items;
    ButtonEx buyOneBtn;
    ButtonEx buyTenBtn;
    Text buyYetCnt;
    Text remainCnt;
    Text priceOne;
    Text priceTen;
    Button lastAwardBtn;
    RichText buyersText;
    Image overImg;
    TextEx nextTime;
 
 
    OperationLuckyCloudBuy operation;
    #region Built-in
    protected override void BindController()
    {
        m_Close = proxy.GetWidgtEx<Button>("CloseButton");
        bigItemCell = proxy.GetWidgtEx<ItemCell>("BigGift");
        bigPrice = proxy.GetWidgtEx<Text>("bigprice");
        items = proxy.GetWidgtEx<ScrollerController>("Scroller");
        buyOneBtn = proxy.GetWidgtEx<ButtonEx>("buyonebtn");
        buyTenBtn = proxy.GetWidgtEx<ButtonEx>("buytenbtn");
        buyYetCnt = proxy.GetWidgtEx<Text>("buycntyet");
        remainCnt = proxy.GetWidgtEx<Text>("opencnt");
        priceOne = proxy.GetWidgtEx<Text>("priceone");
        priceTen = proxy.GetWidgtEx<Text>("priceten");
        lastAwardBtn = proxy.GetWidgtEx<Button>("lastaward");
        buyersText = proxy.GetWidgtEx<RichText>("buyertext");
 
        moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype1"));
        moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype2"));
        moneyTypes.Add(proxy.GetWidgtEx<Image>("moneytype3"));
        overImg = proxy.GetWidgtEx<Image>("overimg");
        nextTime = proxy.GetWidgtEx<TextEx>("nextTime");
    }
 
    protected override void AddListeners()
    {
        m_Close.SetListener(()=> {
            CloseWin<LuckyCloudBuyWin>();
        });
 
        buyOneBtn.SetListener(BuyOne);
        buyTenBtn.SetListener(BuyTen);
 
        lastAwardBtn.SetListener(()=> {
            LuckyCloudBuyModel.Instance.QueryLuckyCloudAward((byte)operation.m_ZoneID);
        });
    }
 
    protected override void OnPreOpen()
    {
        QueryBuyersInfo();
        items.OnRefreshCell += OnRefreshCell;
        LuckyCloudBuyModel.Instance.LuckyCloudBuyEvent += DisplayAfterBuy;
        LuckyCloudBuyModel.Instance.LuckyCloudBuyStarNewRound += Display;
 
        OperationBase operationBase;
        if (!OperationTimeHepler.Instance.TryGetOperationTime(LuckyCloudBuyModel.operationType, out operationBase))
        {
            CloseWin<LuckyCloudBuyWin>();
            return;
        }
        operation = operationBase as OperationLuckyCloudBuy;
    }
    protected override void OnAfterOpen()
    {
        Display();
    }
 
    void QueryBuyersInfo()
    {
        if (LuckyCloudBuyModel.Instance.buyersInfo.Count > 0) return;
        var pack = new IL_CC005_tagCGQueryLuckyCloudBuyNumRec();
        GameNetSystem.Instance.SendInfo(pack);
    }
 
 
    protected override void OnPreClose()
    {
        items.OnRefreshCell -= OnRefreshCell;
        LuckyCloudBuyModel.Instance.LuckyCloudBuyEvent -= DisplayAfterBuy;
        LuckyCloudBuyModel.Instance.LuckyCloudBuyStarNewRound -= Display;
    }
 
    #endregion
 
    void Display()
    {
        int superItemID = operation.m_SuperItemID;
        var itemModel = new ItemCellModel(superItemID, false, (ulong)operation.m_SuperItemCount);
        bigItemCell.Init(itemModel);
        bigItemCell.button.SetListener(() => {
            ItemTipUtility.Show(superItemID);
        });
 
        bigPrice.text = operation.m_SuperItemMoneyValue.ToString();
        for (int i = 0; i < moneyTypes.Count; i++)
        {
            moneyTypes[i].SetIconWithMoneyType(operation.m_SuperItemMoneyType);
        }
 
        items.Refresh();
 
        for (int i = 0; i < operation.m_RandItemList.Count; i++)
        {
            items.AddCell(ScrollerDataType.Header, i);
        }
        items.Restart();
 
        priceOne.text = LuckyCloudBuyModel.Instance.luckyCloudCost[1][1].ToString();
        priceTen.text = LuckyCloudBuyModel.Instance.luckyCloudCost[10][1].ToString();
 
        DisplayAfterBuy();
    }
 
    void DisplayAfterBuy()
    {
        buyYetCnt.text = LuckyCloudBuyModel.Instance.buyCntYet.ToString();
        remainCnt.text = LuckyCloudBuyModel.Instance.remainCnt.ToString();
 
        string showStr = string.Empty;
        for (int i = LuckyCloudBuyModel.Instance.buyersInfo.Count - 1; i >= 0; i--)
        {
            showStr += Language.Get("LuckyCloundBuy2", LuckyCloudBuyModel.Instance.buyersInfo[i].name, LuckyCloudBuyModel.Instance.buyersInfo[i].num);
        }
        buyersText.text = showStr;
 
        overImg.SetActiveIL(LuckyCloudBuyModel.Instance.remainCnt == 0);
        buyOneBtn.SetColorful(null, LuckyCloudBuyModel.Instance.remainCnt != 0);
        buyTenBtn.SetColorful(null, LuckyCloudBuyModel.Instance.remainCnt != 0);
        if (operation.IsOver())
        {
            var timeList = operation.GetStartTime();
            if (timeList == null)
                nextTime.text = Language.Get("LuckyCloudTime2");
            else
                nextTime.text = Language.Get("LuckyCloudTime1", timeList[0].ToString("D2") + ":" + timeList[1].ToString("D2"));
        }
        else
        {
            nextTime.text = string.Empty;
        }
    }
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var _cell = cell.GetComponentEx<ItemCell>();
        int index = cell.index;
        int itemID = operation.m_RandItemList[index].id;
        var itemModel = new ItemCellModel(itemID, false, (ulong)operation.m_RandItemList[index].count);
        _cell.Init(itemModel);
        _cell.button.SetListener(() => {
            ItemTipUtility.Show(itemID);
        });
    }
 
    void BuyOne()
    {
        LuckyCloudBuyModel.Instance.LuckyCloudBuy(1);
    }
 
    void BuyTen()
    {
        LuckyCloudBuyModel.Instance.LuckyCloudBuy(10);
    }
}