少年修仙传客户端代码仓库
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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
using System;
using System.Collections;
using System.Collections.Generic;
 
using UnityEngine;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    
    public class SuperValueGiftBehaviour : MonoBehaviour
    {
        [SerializeField] int m_PayType = 0;
        [SerializeField] Text m_Cost;
        [SerializeField] RareItem[] m_Items;
        [SerializeField] Button m_Buy;
        [SerializeField] Image m_AreadyBuySign;
        [SerializeField] Text m_Remind;
 
        public int payType
        {
            get { return m_PayType; }
        }
 
        OSGiftModel model
        {
            get { return ModelCenter.Instance.GetModel<OSGiftModel>(); }
        }
 
        VipModel vipModel
        {
            get { return ModelCenter.Instance.GetModel<VipModel>(); }
        }
 
        PetModel petModel
        {
            get { return ModelCenter.Instance.GetModel<PetModel>(); }
        }
 
        ReikiRootModel reikiRootModel
        {
            get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); }
        }
 
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
 
        int rechargeId = 0;
 
        private void Awake()
        {
            m_Buy.onClick.AddListener(Buy);
            for (int i = 0; i < m_Items.Length; i++)
            {
                var _index = i;
                m_Items[i].button.onClick.AddListener(() =>
                {
                    OnItemClick(_index);
                });
            }
        }
 
        private void OnEnable()
        {
            vipModel.rechargeCountEvent += RechargeCountEvent;
        }
 
        private void OnDisable()
        {
            vipModel.rechargeCountEvent -= RechargeCountEvent;
        }
 
        private void RechargeCountEvent(int id)
        {
            if (id == rechargeId)
            {
                Display(rechargeId);
            }
        }
 
        private void OnItemClick(int index)
        {
            if (rechargeId != 0)
            {
                List<Item> items;
                if (vipModel.TryGetRechargeItem(rechargeId, out items))
                {
                    if (index < items.Count)
                    {
                        var item = items[index];
                        ItemTipUtility.Show(item.id);
                    }
                }
            }
        }
 
        private void Buy()
        {
            if (rechargeId != 0)
            {
                VipModel.RechargeCount rechargeCount;
                if (vipModel.TryGetRechargeCount(rechargeId, out rechargeCount))
                {
                    if (rechargeCount.totalCount >= 1)
                    {
                        return;
                    }
                }
                vipModel.CTG(rechargeId);
            }
        }
 
        public void Display(int id)
        {
            rechargeId = id;
            List<Item> items;
            bool hasItem = vipModel.TryGetRechargeItem(id, out items);
            for (int i = 0; i < m_Items.Length; i++)
            {
                if (hasItem && i < items.Count)
                {
                    m_Items[i].SetActive(true);
                    var _item = items[i];
                    var _itemModel = new ItemCellModel(_item.id, false, (ulong)_item.count);
                    m_Items[i].SetItemRare(_itemModel, i == 0);
                }
                else
                {
                    m_Items[i].SetActive(false);
                }
            }
 
            var config = CTGConfig.Get(id);
            if (config != null)
            {
                OrderInfoConfig orderInfoConfig;
                if (vipModel.TryGetOrderInfo(id, out orderInfoConfig))
                {
                    m_Cost.text = Language.Get("SuperValueGiftCost", UIHelper.GetMoneyFormat((int)orderInfoConfig.PayRMBNum));
                }
            }
 
            VipModel.RechargeCount rechargeCount;
            bool alreadyBuy = false;
            if (vipModel.TryGetRechargeCount(id, out rechargeCount))
            {
                alreadyBuy = rechargeCount.totalCount >= config.TotalBuyCount;
            }
            m_Buy.SetActive(!alreadyBuy);
            m_AreadyBuySign.SetActive(alreadyBuy);
 
            if (m_Remind != null)
            {
                m_Remind.SetActive(config.PayType == 7
                    || config.PayType == 11);
                if (config.PayType == 7)
                {
                    var petId = 0;
                    var level = 0;
                    model.GetPetInfo(out petId, out level);
                    var point = model.GetSkillActivePoint(PlayerDatas.Instance.baseData.LV);
                    var petConfig = PetInfoConfig.Get(petId);
                    m_Remind.text = Language.Get("OpenServerGiftRemind7", petConfig.Name, level, point);
                }
                else if (config.PayType == 11)
                {
                    var totalPoint = 0;
                    if (PlayerDatas.Instance.baseData.LV >= reikiRootModel.reikiPointAutoAddLevel)
                    {
                        var level = PlayerDatas.Instance.baseData.LV - reikiRootModel.reikiPointAutoAddLevel + 1;
                        totalPoint = level * reikiRootModel.titleAddPoint.point;
                    }
                    m_Remind.text = Language.Get("OpenServerGiftRemind11", totalPoint);
                }
            }
        }
    }
}