少年修仙传客户端代码仓库
client_linchunjie
2018-09-19 aecb6a5a62d8a4cfc7b924ce957a9c7ea90c235d
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
using System;
 
namespace Snxxz.UI
{
    public class RechargeBehaviour : MonoBehaviour
    {
        [SerializeField] Button m_ChargeButton;
        [SerializeField] RectTransform m_ContainerTitle;
        [SerializeField] Image m_ChargeIcon;
        [SerializeField] Text m_PriceValue;
        [SerializeField] Text m_GetGoldValue;
        [SerializeField] RectTransform m_ContainerAdded;
        [SerializeField] Text m_AddedValue;
        [SerializeField] Image m_BuyLimitIcon;
        [SerializeField] Image m_BuyComplete;
        [SerializeField] Image m_FirstBuy;
 
        VipModel m_Model;
        VipModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<VipModel>());
            }
        }
 
        public int chargeId { get; private set; }
 
        private void Awake()
        {
            m_ChargeButton.onClick.AddListener(OnChargeClick);
        }
 
        public void Display(int _id)
        {
            var _ctgConfig = Config.Instance.Get<CTGConfig>(_id);
            if (_ctgConfig == null)
            {
                return;
            }
            chargeId = _id;
            if (m_ContainerTitle != null)
            {
                //m_Title.text = _ctgConfig.Title;
            }
            m_ChargeIcon.SetSprite(_ctgConfig.Icon);
            m_PriceValue.text = StringUtility.Contact("¥", model.GetPayRmb(_ctgConfig.RecordID));
            m_GetGoldValue.gameObject.SetActive(_ctgConfig.GainGold > 0);
            if(_ctgConfig.GainGold > 0)
            {
                m_GetGoldValue.text = _ctgConfig.GainGold.ToString();
            }
            VipModel.RechargeCount _rechargeCount;
            bool _firstRecharge = true;
            if (model.TryGetRechargeCount(_id, out _rechargeCount))
            {
                if (_rechargeCount.totalCount > 0)
                {
                    _firstRecharge = false;
                }
                if (m_BuyComplete != null)
                {
                    m_BuyComplete.gameObject.SetActive(_ctgConfig.DailyBuyCount > 0 &&
                                        _ctgConfig.DailyBuyCount <= _rechargeCount.todayCount);
                }
            }
            m_ContainerAdded.gameObject.SetActive((_firstRecharge && _ctgConfig.FirstGoldPaperPrize > 0)
                || _ctgConfig.GainGoldPaper > 0);
            if(_firstRecharge && _ctgConfig.FirstGoldPaperPrize > 0)
            {
                m_AddedValue.text = _ctgConfig.FirstGoldPaperPrize.ToString();
            }
            else if (_ctgConfig.GainGoldPaper > 0)
            {
                m_AddedValue.text = _ctgConfig.GainGoldPaper.ToString();
            }
 
            if (m_BuyLimitIcon != null)
            {
                m_BuyLimitIcon.gameObject.SetActive(_ctgConfig.PayType == 1 && _ctgConfig.DailyBuyCount > 0 && !_firstRecharge);
            }
            if (m_FirstBuy != null)
            {
                m_FirstBuy.gameObject.SetActive(_ctgConfig.PayType == 1 && _firstRecharge);
            }
        }
 
        private void OnChargeClick()
        {
            var _ctgConfig = Config.Instance.Get<CTGConfig>(chargeId);
            if (_ctgConfig != null)
            {
                if (model.m_RechargeGainItemDict.ContainsKey(chargeId))
                {
                    model.ShowRechargeBox(chargeId);
                    return;
                }
                model.CTG(chargeId);
            }
        }
    }
}