少年修仙传客户端代码仓库
lcy
2024-09-13 a7ec5ce85c5eb849ec64a6900a8cc18f01efe5c6
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Wednesday, September 26, 2018
//--------------------------------------------------------
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
 
namespace vnxbqy.UI
{
 
    public class CustomizedGiftCell : CellView
    {
        [SerializeField] Text title;
        [SerializeField] Text saleValue;
        [SerializeField] Text limiteBuyCntText;
        [SerializeField] List<CustomizedItemCell> itemCells;
        [SerializeField] Button buyBtn;
        [SerializeField] Text priceText;
        [SerializeField] Button haveBtn;
        [SerializeField] Image buyYetImg;
        [SerializeField] Image haveYetImg;
        [SerializeField] ImageEx ImgSale;
        int girdIndex = 0;
 
        CustomizedGiftModel model { get { return ModelCenter.Instance.GetModel<CustomizedGiftModel>(); } }
        CustomizedRechargeModel crModel { get { return ModelCenter.Instance.GetModel<CustomizedRechargeModel>(); } }
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
 
 
        public void Display(int index)
        {
            OperationRechargeGiftAct act;
            if (!OperationTimeHepler.Instance.TryGetOperation(CustomizedGiftModel.operaType, out act))
            {
                return;
            }
            //免费礼包
            if (model.IsFree(index))
            {
                ImgSale.SetActive(false);
                buyBtn.SetActive(false);
                buyYetImg.SetActive(false);
                limiteBuyCntText.SetActive(false);
                haveBtn.SetActive(true);
                title.text = Language.Get("CustomizedGift02");
                int totalBuyCnt = model.GetBuyTotalCnt();
                var awardInfo = act.buyCountGifts[index];
                for (int i = 0; i < itemCells.Count; i++)
                {
                    if (i < awardInfo.AwardItemList.Length)
                    {
                        var award = awardInfo.AwardItemList[i];
                        itemCells[i].button.interactable = true;
                        itemCells[i].SetActive(true);
                        var itemData = new ItemCellModel((int)award.ItemID, false, award.ItemCount);
                        itemCells[i].Init(itemData);
                        itemCells[i].button.SetListener(() =>
                        {
                            ItemTipUtility.Show((int)award.ItemID);
                        });
                    }
                    else
                    {
                        itemCells[i].SetActive(false);
                    }
                }
                haveBtn.SetColorful(null, totalBuyCnt >= awardInfo.NeedBuyCount);
                haveBtn.interactable = totalBuyCnt >= awardInfo.NeedBuyCount;
                haveBtn.SetListener(() =>
                {
                    model.SendGetAward(awardInfo.NeedBuyCount);
                });
 
                if (index == act.buyCountGifts.Count - 1 && model.GetBuyGiftState(awardInfo.NeedBuyCount) == 2)
                {
                    haveYetImg.SetActive(true);
                    haveBtn.SetActive(false);
                }
                else
                {
                    haveYetImg.SetActive(false);
                    haveBtn.SetActive(true);
                }
            }
            //付费礼包
            else
            {
                haveBtn.SetActive(false);
                haveYetImg.SetActive(false);
                limiteBuyCntText.SetActive(true);
                ImgSale.SetActive(true);
 
                int actCtgIndex = index - 1;
                int ctgID = act.ctgIDs[actCtgIndex];
 
                crModel.ShowUIItems(itemCells, ctgID);
 
                var ctgConfig = CTGConfig.Get(ctgID);
                title.text = ctgConfig.Title;
                saleValue.text = Language.Get("RechargeGiftActWin3", ctgConfig.Percentage);
                var countInfo = model.GetBuyCntInfo(ctgID);
                int buyCnt = countInfo.x;
                int totalCnt = countInfo.y;
                limiteBuyCntText.text = Language.Get("RechargeGiftActWin4", UIHelper.AppendColor(buyCnt >= totalCnt ? TextColType.Red : TextColType.Green, buyCnt + "/" + totalCnt, true));
                buyBtn.SetActive(buyCnt < totalCnt);
                buyBtn.SetListener(() =>
                {
                    vipModel.CTG(ctgID);
                });
                buyYetImg.SetActive(buyCnt >= totalCnt);
                OrderInfoConfig orderConfig;
                vipModel.TryGetOrderInfo(ctgID, out orderConfig);
                priceText.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat((long)orderConfig.PayRMBNum));
            }
        }
 
 
    }
 
}