少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using System.Collections.Generic;
using UnityEngine;
 
namespace vnxbqy.UI
{
    public class CycleHallGiftCell : CellView
    {
        [SerializeField] TextEx txtTitle;
        [SerializeField] List<ItemCell> giftItemCells = new List<ItemCell>();
        [SerializeField] ButtonEx btnBuy;
        [SerializeField] ImageEx imgRed;
        [SerializeField] TextEx txtBuy;
        [SerializeField] ImageEx imgBuy;
        [SerializeField] TextEx txtLimitCount;
 
        [SerializeField] TextEx orgPrice;
        int roundType;
 
        CycleHallActModel model { get { return ModelCenter.Instance.GetModel<CycleHallActModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
 
        public void Display(int index, CellView cellView)
        {
            roundType = cellView.info.Value.infoInt1;
            imgRed.SetActive(false);
            if (model.playerInfoDict == null || !model.playerInfoDict.TryGetValue((byte)roundType, out var playerInfo) || playerInfo == null)
                return;
 
            var act = model.GetOperationInfo();
            if (act == null || !act.TryGetRound(roundType, out var round) || round.CTGIDList == null)
                return;
            List<StoreConfig> _list = null;
            StoreConfig.TryGetStoreConfigs(round.ShopType, out _list);
            if (_list != null && index < _list.Count)
            {
                DisplayStore(_list[index]);
                return;
            }
            index = index - (_list != null ? _list.Count : 0);
            if (round.CTGIDList.Length <= index || index < 0)
                return;
            int ctgId = round.CTGIDList[index];
            if (!CTGConfig.Has(ctgId))
                return;
            CTGConfig config = CTGConfig.Get(ctgId);
 
            var countInfo = GetBuyCntInfo(ctgId);
            int buyCnt = countInfo.x;
            int totalCnt = countInfo.y;
            btnBuy.SetActive(buyCnt < totalCnt);
            imgBuy.SetActive(buyCnt >= totalCnt);
            OrderInfoConfig orderConfig;
            vipModel.TryGetOrderInfo(ctgId, out orderConfig);
            txtBuy.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.PayRMBNum));
            txtLimitCount.SetActive(true);
            txtLimitCount.text = Language.Get("CycleHall05", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.Green, Mathf.Max(0, totalCnt - buyCnt).ToString(), true));
            if (orgPrice != null)
            {
                orgPrice.SetActive(PlayerDatas.Instance.baseData.IsActive90Off);
                orgPrice.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(orderConfig.m_PayRMBNum));
            }
            btnBuy.SetListener(() =>
            {
                if (PlayerDatas.Instance.baseData.VIPLv < config.VipLevel)
                {
                    SysNotifyMgr.Instance.ShowTip("VIPNotEnough", config.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);
                }
            });
 
            txtTitle.text = config.Title;
            if (vipModel.TryGetRechargeItem(ctgId, out var list) && list != null)
            {
                for (int i = 0; i < giftItemCells.Count; i++)
                {
                    var itemBaisc = giftItemCells[i];
                    if (i < list.Count)
                    {
                        var itemInfo = list[i];
                        itemBaisc.SetActive(true);
                        ItemCellModel cellModel = new ItemCellModel((int)itemInfo.id, false, (ulong)itemInfo.count);
                        itemBaisc.Init(cellModel);
                        itemBaisc.button.AddListener(() =>
                        {
                            ItemTipUtility.Show((int)itemInfo.id);
                        });
                    }
                    else
                    {
                        itemBaisc.SetActive(false);
                    }
                }
            }
        }
 
        public Int2 GetBuyCntInfo(int ctgID)
        {
            VipModel.RechargeCount rechargeCount;
            vipModel.TryGetRechargeCount(ctgID, out rechargeCount);
 
            var ctgConfig = CTGConfig.Get(ctgID);
            int buyCnt = 0;
            int totalCnt = 0;
 
            buyCnt = rechargeCount.totalCount;
            totalCnt = ctgConfig.TotalBuyCount;
 
            return new Int2(buyCnt, totalCnt);
        }
 
        private void DisplayStore(StoreConfig storeConfig)
        {
            bool isFree = storeConfig.MoneyNumber == 0;
            txtTitle.text = isFree ? Language.Get("StoreName_free") : Language.Get("StoreName_money");
            //saleObj.SetActive(false);
            int remainNum;
            storeModel.TryGetIsSellOut(storeConfig, out remainNum);
            orgPrice.SetActive(false);
            txtLimitCount.SetActive(!isFree);
            txtLimitCount.text = Language.Get("CycleHall06", UIHelper.AppendColor(remainNum == 0 ? TextColType.Red : TextColType.Green, Mathf.Max(0, remainNum).ToString(), true));
 
            imgRed.SetActive(isFree);
            btnBuy.SetActive(remainNum > 0);
            btnBuy.SetListener(() =>
            {
                storeModel.SendBuyShopItemWithPopCheck(storeConfig, 1, (int)BuyStoreItemCheckType.ActGift);
            });
            imgBuy.SetActive(remainNum <= 0);
 
            txtBuy.text = isFree ? Language.Get("AloneFree") : Language.Get("ItemOverdue105", UIHelper.GetMoneyFormat(storeConfig.MoneyNumber));
 
            var items = storeModel.GetShopItemlistByIndex(storeConfig);
            for (int i = 0; i < giftItemCells.Count; i++)
            {
                var itemBaisc = giftItemCells[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);
                }
            }
        }
    }
}