少年修仙传客户端代码仓库
hch
2019-10-31 3c35f85432d317061f09c93319108de899469d55
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class AddUpRechargeBehaviour : CellView
    {
        [SerializeField] Text m_Title;
        [SerializeField] RareItem[] m_Items;
        [SerializeField] Text m_Progress;
        [SerializeField] Button m_GetReward;
        [SerializeField] Transform m_Complete;
        [SerializeField] Text m_btnText;
 
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
        AddUpRechargeModel model { get { return ModelCenter.Instance.GetModel<AddUpRechargeModel>(); } }
 
        public void Display(int id)
        {
            var config = AddUpRechargeConfig.Get(id);
            m_Title.text = string.Format("累计充值<color=#4AF25D>{0}</color>可领取", config.Recharge);
 
            List<Item> items;
            model.TryGetItems(id, out items);
            for (int i = 0; i < m_Items.Length; i++)
            {
                if (items != null && i < items.Count)
                {
                    m_Items[i].gameObject.SetActive(true);
                    var item = items[i];
                    var itemData = new ItemCellModel(item.id, true, (ulong)item.count);
                    m_Items[i].SetItemRare(itemData, item.quality == 1);
                    m_Items[i].button.SetListener(() =>
                    {
                        ItemTipUtility.Show(item.id);
                    });
                }
                else
                {
                    m_Items[i].gameObject.SetActive(false);
                }
            }
 
            var state = model.GetAddUpRechargeState(id);
            m_Progress.gameObject.SetActive(true);
            m_Complete.gameObject.SetActive(state == 1);
            m_GetReward.gameObject.SetActive(state != 1);
            m_btnText.text = state == 0 ? "领取" : "前往充值";
            switch (state)
            {
                case -1:
                    m_Progress.text = StringUtility.Contact(string.Format("(再充值<color=#4AF25D>{0}</color>可达成)", config.Recharge - PlayerDatas.Instance.baseData.coinPointTotal * 0.01));
                    break;
                default:
                    m_Progress.text = StringUtility.Contact("<color=#4AF25D>(已达成)</color>");
                    break;
            }
 
            m_GetReward.SetListener(() =>
            {
                if (state == 0)
                    model.SendGetReward(id);
                else
                {
                    if (VersionConfig.Get().isBanShu)
                    {
                        SysNotifyMgr.Instance.ShowTip("FuncNoOpen_Nowaday");
                        return;
                    }
                    if (FuncOpen.Instance.IsFuncOpen(113))
                    {
                        WindowCenter.Instance.Close<AddUpRechargeWin>();
                        ModelCenter.Instance.GetModel<VipModel>().OpenVipPayUI(VipModel.VipWinType.Pay);
                    }
                    else
                    {
                        FuncOpen.Instance.ProcessorFuncErrorTip(113);
                    }
                }
 
            });
        }
    }
}