少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class RechargeWin : Window
    {
        [SerializeField] RechargeBehaviour[] m_Recharges;
        [SerializeField] Text m_GoldValue;
        [SerializeField] Button m_SpecialRechargeBtn;
        [SerializeField] Transform cashObj;
        [SerializeField] Text gameCashNum;
        [SerializeField] Text timeGameCash; //限时代金券
 
 
        VipModel m_Model;
        VipModel model
        {
            get
            {
                return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<VipModel>());
            }
        }
 
        protected override void BindController()
        {
 
        }
 
        protected override void AddListeners()
        {
            m_SpecialRechargeBtn.onClick.AddListener(SpecialRecharge);
        }
 
        protected override void OnPreClose()
        {
            PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshInfoEvent;
            model.rechargeCountEvent -= RechargeCountEvent;
            if (model.rechargeGiftRedpoint.state == RedPointState.Simple)
            {
                model.SetViewedRechargeGift();
            }
        }
 
        protected override void OnPreOpen()
        {
            Display();
            UpdateGoldValue();
            PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshInfoEvent;
            model.rechargeCountEvent += RechargeCountEvent;
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        protected override void OnAfterOpen()
        {
 
        }
 
        private void PlayerDataRefreshInfoEvent(PlayerDataType _type)
        {
            switch (_type)
            {
                case PlayerDataType.Gold:
                case PlayerDataType.default5:
                case PlayerDataType.ExAttr11:
                case PlayerDataType.default41:
                    UpdateGoldValue();
                    break;
            }
        }
 
        void Display()
        {
            var _list = model.GetCTGConfigs(VersionConfig.Get().appId);
            var _index = 0;
            for (int i = 0; i < _list.Count; i++)
            {
                var config = CTGConfig.Get(_list[i]);
                if (config == null || (config.PayType != 1 && config.PayType != 2))
                {
                    continue;
                }
                if (_index >= m_Recharges.Length) break;
                m_Recharges[_index].SetActive(true);
                m_Recharges[_index].Display(_list[i]);
                _index++;
            }
            for (int i = _index; i < m_Recharges.Length; i++)
            {
                m_Recharges[i].SetActive(false);
            }
            var _specialIndex = _list.FindIndex((x) =>
            {
                var config = CTGConfig.Get(x);
                return config != null && config.PayType == 3;
            });
            m_SpecialRechargeBtn.SetActive(_specialIndex != -1 && PlayerDatas.Instance.baseData.VIPLv >= GeneralDefine.supremeRechargeVipLv);
            
        }
 
        private void SpecialRecharge()
        {
            var _list = model.GetCTGConfigs(VersionConfig.Get().appId);
            var _specialIndex = _list.FindIndex((x) =>
            {
                var config = CTGConfig.Get(x);
                return config != null && config.PayType == 3;
            });
            if (_specialIndex != -1)
            {
                WindowCenter.Instance.Open<SupremeRechargeWin>();
            }
        }
 
        void UpdateGoldValue()
        {
            m_GoldValue.text = UIHelper.ReplaceLargeNum(UIHelper.GetMoneyCntEx(1));
            var gameCash = UIHelper.GetAllVourcher()/100.0f;
            //cashObj.SetActive(gameCash > 0);
            gameCashNum.text = gameCash.ToString("0.##");// + Language.Get("GameCash");
            timeGameCash.text = Language.Get("mr648tip3", (UIHelper.GetMoneyCnt(98) / 100.0f).ToString("0.##"));
        }
 
        private void RechargeCountEvent(int _id)
        {
            var config = CTGConfig.Get(_id);
            if (config == null || (config.PayType != 1 && config.PayType != 2))
            {
                return;
            }
            for (int i = 0; i < m_Recharges.Length; i++)
            {
                if (m_Recharges[i].chargeId == _id)
                {
                    m_Recharges[i].Display(_id);
                    break;
                }
            }
        }
    }
}