少年修仙传客户端代码仓库
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
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class SingleRechargeSumCell : CellView
    {
        [SerializeField] Text m_Consume;
        [SerializeField] RareItem[] m_RebateItems;
        [SerializeField] Button m_GetBtn;
        [SerializeField] UIEffect m_GetSfx;
        [SerializeField] Image m_GotSign;
 
        SingleRechargeSumModel model { get { return ModelCenter.Instance.GetModel<SingleRechargeSumModel>(); } }
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
 
        
        public void Display(int _index)
        {
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(SingleRechargeSumModel.operType, out operationBase))
            {
                OperationSingleRecharge operation = operationBase as OperationSingleRecharge;
                var keys = operation.singleRechargeAwards.Keys.ToList();
                keys.Sort();
                
                var awards = operation.singleRechargeAwards[keys[_index]];
 
                m_Consume.text = Language.Get("PayMoneyNum", UIHelper.GetMoneyFormat(keys[_index]));
 
                for (int i = 0; i < m_RebateItems.Length; i++)
                {
                    if (i < awards.Count)
                    {
                        var itemDate = awards[i];
                        m_RebateItems[i].SetActive(true);
                        ItemCellModel itemCell = new ItemCellModel(itemDate.id, true, (ulong)itemDate.count);
                        m_RebateItems[i].Init(itemCell);
                        m_RebateItems[i].button.AddListener(() =>
                        {
                            ItemTipUtility.Show(itemDate.id);
                        });
                    }
                    else
                    {
                        m_RebateItems[i].SetActive(false);
                    }
                }
 
                int state = model.GetRewardState(_index);
 
                m_GetBtn.SetActive(state != 2);
                m_GetBtn.interactable = state == 1;
                m_GetBtn.SetColorful(null, state == 1);
                m_GotSign.SetActive(state == 2);
                m_GetSfx.SetActive(state == 1);
 
                m_GetBtn.AddListener(() => {
                    GetReward(_index);
                });
 
                Text activityCountText = m_Consume.FindComponent("Text", "Text_AllCount") as Text;
                Text canGetCountText = m_Consume.FindComponent("Text", "Text_CanCount") as Text;
 
                int maxCount = model.GetMaxRewardCnt(index);
                int canGetCount = model.GetCanRewardGetCnt(index);
                int gotCount = model.GetRewardGotCnt(index);
 
                activityCountText.text = Language.Get("SingleRecharge2", maxCount - canGetCount, maxCount);
                if (canGetCount - gotCount <= 0)
                {
                    canGetCountText.text = string.Empty;
                }
                else
                { 
                    canGetCountText.text = Language.Get("SingleRecharge3", canGetCount - gotCount);
                }
            }
        }
 
        private void GetReward(int index)
        {
            OperationBase operationBase;
            if (OperationTimeHepler.Instance.TryGetOperationTime(SingleRechargeSumModel.operType, out operationBase))
            {
                var operation = operationBase as OperationSingleRecharge;
            }
            var count = packModel.GetEmptyGridCount(PackType.Item);
            if (count < 4)
            {
                SysNotifyMgr.Instance.ShowTip("BagFull");
                return;
            }
            model.SendGetReward(index);
        }
    }
}