少年修仙传客户端代码仓库
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
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
 
namespace vnxbqy.UI
{
    public class CrossServerOneVsOneHonorShopCell : MonoBehaviour
    {
        [SerializeField] ItemCell itemCell;
        [SerializeField] Text nameText;
        [SerializeField] Image moneyIcon;
        [SerializeField] Text moneyCntText;
        [SerializeField] Text vipText;
        [SerializeField] Image stateImg;
        [SerializeField] Image sellImg;
        [SerializeField] Button shopCellBtn;
        [SerializeField] Text refreshTimeText;
        [SerializeField] RedpointBehaviour redpointBeh;
 
        StoreModel m_storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
 
        public void SetDisplay(StoreConfig storeConfig, int recommendGoodId)
        {
            ItemConfig itemConfig = ItemConfig.Get(m_storeModel.GetReplaceId(storeConfig.ID, storeConfig.ItemID));
            if (itemConfig == null) return;
 
            Redpoint redpoint = crossServerModel.GetRedpointById(storeConfig.ID);
            if (redpoint != null)
            {
                redpointBeh.redpointId = redpoint.id;
            }
            ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, 0, "", PackType.Deleted, true);
            itemCell.button.enabled = false;
            itemCell.Init(cellModel);
            nameText.text = itemConfig.ItemName;
            nameText.color = UIHelper.GetUIColor(itemConfig.ItemColor, true);
            moneyIcon.SetIconWithMoneyType(storeConfig.MoneyType);
            ulong shopCost = (ulong)(storeConfig.MoneyNumber);
            moneyCntText.text = UIHelper.ReplaceLargeNum(shopCost);
            sellImg.SetActive(false);
            if (!string.IsNullOrEmpty(storeConfig.SalesStatus))
            {
                stateImg.SetActive(true);
                stateImg.SetSprite(storeConfig.SalesStatus);
                stateImg.SetNativeSize();
            }
            else
            {
                stateImg.SetActive(false);
            }
 
            int canBuyCnt = 0;
            int addBuyCnt = 0;
            int curVipIndex = -1;
            int nextVipIndex = -1;
            bool isVipBuy = BuyItemController.Instance.CheckIsVipBuy(storeConfig, out curVipIndex, out nextVipIndex);
            bool isLimitBuy = BuyItemController.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt);
            bool isShowBuyPrice = true;
            if (isVipBuy)
            {
                if (curVipIndex == -1 && nextVipIndex != -1)
                {
                    vipText.text = Language.Get("StoreWin101", storeConfig.VIPLV[nextVipIndex]);
                    nameText.color = UIHelper.GetUIColor(TextColType.Red, true);
                    vipText.color = UIHelper.GetUIColor(TextColType.Red, true);
                    isShowBuyPrice = false;
                }
            }
 
            vipText.SetActive(!isShowBuyPrice);
            refreshTimeText.SetActive(false);
            moneyIcon.SetActive(isShowBuyPrice);
            if (canBuyCnt > 0)
            {
                itemCell.countText.SetActive(true);
                BuyShopItemLimit shopItemLimit = m_storeModel.GetBuyShopLimit((uint)storeConfig.ID);
                int remainNum = canBuyCnt;
                if (shopItemLimit != null)
                {
                    remainNum = canBuyCnt - shopItemLimit.BuyCnt;
                }
 
                if (remainNum > 0)
                {
                    itemCell.countText.text = StringUtility.Contact(remainNum.ToString(),
                        "/" + canBuyCnt.ToString());
                }
                else
                {
                    stateImg.SetActive(false);
                    sellImg.SetActive(true);
                    itemCell.countText.text = StringUtility.Contact(UIHelper.AppendColor(TextColType.Red, remainNum.ToString()),
                        "/" + canBuyCnt.ToString());
                    string refreshDes = m_storeModel.GetStoreRefreshTimeByType(storeConfig.RefreshType);
                    if (!string.IsNullOrEmpty(refreshDes))
                    {
                        refreshTimeText.SetActive(true);
                        refreshTimeText.text = refreshDes;
                    }
                }
            }
            else
            {
                itemCell.countText.SetActive(false);
            }
 
            if (storeConfig.ID == recommendGoodId)
            {
                DisplayRecommendEffect();
            }
            else
            {
                RecycleRecommendEffect();
            }
 
            shopCellBtn.RemoveAllListeners();
            shopCellBtn.AddListener(() =>
            {
                m_storeModel.OnClickShopCell(storeConfig);
                crossServerModel.ClearRedpoint(storeConfig.ID);
            });
        }
 
        AchievementGuideEffect recommendEffect;
        private void DisplayRecommendEffect()
        {
            RecycleRecommendEffect();
            recommendEffect = AchievementGuideEffectPool.Require(7);
            recommendEffect.transform.SetParentEx(this.transform, Vector3.zero, Quaternion.identity, Vector3.one);
            recommendEffect.effect.SetMask();
        }
 
        private void RecycleRecommendEffect()
        {
            if (recommendEffect != null)
            {
                AchievementGuideEffectPool.Recycle(recommendEffect);
                recommendEffect = null;
            }
        }
 
    }
}