少年修仙传客户端代码仓库
hch
2025-07-02 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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, June 11, 2019
//--------------------------------------------------------
 
using vnxbqy.UI;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
 
 
public class NewGuyGiftWin : ILWindow
{
 
    Button m_Close;
    List<ItemCell> awardList = new List<ItemCell>();
    Image state;
    Button Btn_Buy;
    Text buyText;
    Text title;
    Text timeText;
    Text saleInfo;
    TextEx orgPrice;
 
    VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
 
    int ctgID = 0;
 
    #region Built-in
    protected override void BindController()
    {
        m_Close = proxy.GetWidgtEx<Button>("closebtn");
        for (int i = 0; i < 5; i++)
        {
            awardList.Add(proxy.GetWidgtEx<ItemCell>("itemcell" + i));
        }
 
        Btn_Buy = proxy.GetWidgtEx<Button>("buybtn");
        state = proxy.GetWidgtEx<Image>("ImageEx");
        buyText = proxy.GetWidgtEx<Text>("buytext");
        title = proxy.GetWidgtEx<Text>("title");
        timeText = proxy.GetWidgtEx<Text>("time");
        saleInfo = proxy.GetWidgtEx<Text>("saleinfo");
        var obj = Btn_Buy.FindComponent("Text", "Txt_orgPrice");
        if (obj != null)
            orgPrice = obj as TextEx;
    }
 
    protected override void AddListeners()
    {
        m_Close.SetListener(()=> {
            CloseWin<NewGuyGiftWin>();
        });
 
        Btn_Buy.SetListener(() => {
            if (ctgID == 0) return;
            vipModel.CTG(ctgID);
            NewGuyGiftModel.Instance.buyPlayerID = (int)PlayerDatas.Instance.PlayerId;
            NewGuyGiftModel.Instance.buyCTGID = ctgID;
        });
    }
 
    protected override void OnPreOpen()
    {
        ctgID = NewGuyGiftModel.Instance.RefreshShowCtgID();
        GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
        vipModel.rechargeCountEvent += OnRechargeCountEvent;
        Display();
        
    }
 
    protected override void OnAfterOpen()
    {
    }
 
    protected override void OnPreClose()
    {
        GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
        vipModel.rechargeCountEvent -= OnRechargeCountEvent;
    }
    #endregion
 
    void Display()
    {
        if (ctgID == 0)
        {
            return;
        }
        List<Item> itemList;
        vipModel.TryGetRechargeItem(ctgID, out itemList);
        for (int i = 0; i < awardList.Count; i++)
        {
            if (i < itemList.Count)
            {
                awardList[i].SetActiveIL(true);
                var itemId = itemList[i].id;
                var model = new ItemCellModel(itemId, false, (ulong)itemList[i].count);
                awardList[i].Init(model);
                awardList[i].button.SetListener(() =>
                {
                    ItemTipUtility.Show(itemId);
                });
            }
            else
            {
                awardList[i].SetActiveIL(false);
            }
        }
        VipModel.RechargeCount rechargeCount;
        vipModel.TryGetRechargeCount(ctgID, out rechargeCount);
 
        state.SetActiveIL(rechargeCount.totalCount > 0);
        Btn_Buy.SetActiveIL(rechargeCount.totalCount == 0);
        OrderInfoConfig config;
        vipModel.TryGetOrderInfo(ctgID, out config);
        buyText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.PayRMBNum));
        if (orgPrice != null)
        {
            orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
            orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(config.m_PayRMBNum));
        }
        var ctgConfig = CTGConfig.Get(ctgID);
        title.text = ctgConfig.Title;
        saleInfo.text = Language.Get("SaleOffInfo02", ctgConfig.Percentage);
    }
 
    void OnSecondEvent()
    {
        if (ctgID == 0)
        {
            CloseWin<NewGuyGiftWin>();
            return;
        }
        timeText.text = TimeUtility.SecondsToHMS(NewGuyGiftModel.Instance.GetShowCTGTime());
    }
 
    void OnRechargeCountEvent(int ctgid)
    {
        Display();
    }
}