少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, September 26, 2018
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using System.Collections.Generic;
 
namespace vnxbqy.UI
{
    public class FairyAffinityRechargeGiftActCell : CellView
    {
        [SerializeField] Text title;
        [SerializeField] ImageEx bg;
        [SerializeField] ImageEx titleBG;
        [SerializeField] List<CustomizedItemCell> itemCells;
        [SerializeField] Button buyBtn;
        [SerializeField] Text priceText;
        [SerializeField] Image buyYetImg;
        [SerializeField] Image imgProfitRatio;
        [SerializeField] Text txtProfitRatio;
 
        TextEx orgPrice;
 
        FairyAffinityRechargeGiftActModel model { get { return ModelCenter.Instance.GetModel<FairyAffinityRechargeGiftActModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
 
        BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        CustomizedRechargeModel customizedRechargeModel { get { return ModelCenter.Instance.GetModel<CustomizedRechargeModel>(); } }
 
        public void Display(int index)
        {
            OperationRechargeGiftAct act;
            OperationTimeHepler.Instance.TryGetOperation(FairyAffinityRechargeGiftActModel.operaType, out act);
            if (act == null)
                return;
            bg.SetSprite(index % 2 == 0 ? "FairyAffinityGiftBG1" : "FairyAffinityGiftBG2");
            titleBG.SetSprite(index % 2 == 0 ? "FairyAffinityGiftTitleBG1" : "FairyAffinityGiftTitleBG2");
 
            List<StoreConfig> _list = null;
            StoreConfig.TryGetStoreConfigs(act.shopType, out _list);
 
            if (_list != null && index < _list.Count)
            {
                DisplayStore(_list[index]);
                return;
            }
            index = index - (_list != null ? _list.Count : 0);
 
            int ctgID = act.ctgIDs[index];
            var ctgConfig = CTGConfig.Get(ctgID);
            title.text = ctgConfig.Title;
 
            var countInfo = model.GetBuyCntInfo(ctgID);
 
            int buyCnt = countInfo.x;
            int totalCnt = countInfo.y;
 
            customizedRechargeModel.ShowUIItems(itemCells, ctgID);
 
            buyBtn.SetActive(buyCnt < totalCnt);
            buyBtn.SetListener(() =>
            {
                if (PlayerDatas.Instance.baseData.VIPLv < ctgConfig.VipLevel)
                {
                    SysNotifyMgr.Instance.ShowTip("VIPNotEnough", ctgConfig.VipLevel);
                    return;
                }
 
                if (bossTrialModel.IsOpen)
                {
                    //参与时间结束前直接购买,时间结束后再购买需要弹窗提示
                    if (bossTrialModel.IsPrepareTime || bossTrialModel.IsJoin)
                        vipModel.CTG(ctgID);
                    else
                    {
                        ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("BossTrial14"), (bool isOk) =>
                        {
                            if (isOk)
                            {
                                vipModel.CTG(ctgID);
                            }
                        });
                    }
                }
                else
                {
                    vipModel.CTG(ctgID);
                }
            });
            buyYetImg.SetActive(buyCnt >= totalCnt);
 
            OrderInfoConfig orderConfig;
            vipModel.TryGetOrderInfo(ctgID, out orderConfig);
            imgProfitRatio.SetActive(orderConfig != null);
            priceText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat((long)orderConfig.PayRMBNum));
            txtProfitRatio.text = Language.Get("BlessedLand039", ctgConfig.Percentage);
 
            var obj = buyBtn.FindComponent("Text", "Txt_orgPrice");
            if (obj != null)
                orgPrice = obj as TextEx;
            if (orgPrice != null)
            {
                orgPrice.SetActiveIL(PlayerDatas.Instance.baseData.IsActive90Off);
                orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.m_PayRMBNum));
            }
        }
 
        private void DisplayStore(StoreConfig storeConfig)
        {
            bool isFree = storeConfig.MoneyNumber == 0;
            title.text = isFree ? Language.Get("StoreName_free") : Language.Get("StoreName_money");
 
            int remainNum;
            storeModel.TryGetIsSellOut(storeConfig, out remainNum);
 
            var items = storeModel.GetShopItemlistByIndex(storeConfig);
 
            for (int i = 0; i < itemCells.Count; i++)
            {
                var itemBaisc = itemCells[i];
                if (i < items.Count)
                {
                    var itemInfo = items[i];
                    itemBaisc.SetActive(true);
                    ItemCellModel cellModel = new ItemCellModel(itemInfo.itemId, false, (ulong)itemInfo.count);
                    itemBaisc.Init(cellModel);
                    itemBaisc.button.AddListener(() =>
                    {
                        ItemTipUtility.Show(itemInfo.itemId);
                    });
                }
                else
                {
                    itemBaisc.SetActive(false);
                }
            }
 
            buyBtn.SetActive(remainNum > 0);
            buyBtn.SetListener(() =>
            {
                storeModel.SendBuyShopItemWithPopCheck(storeConfig, 1, (int)BuyStoreItemCheckType.ActGift);
            });
            buyYetImg.SetActive(remainNum <= 0);
 
            priceText.text = isFree ? Language.Get("AloneFree") : Language.Get("ItemOverdue105", storeConfig.MoneyNumber);
            imgProfitRatio.SetActive(false);
            //txtProfitRatio.text = Language.Get("BlessedLand039", ctgConfig.Percentage);
        }
    }
}