少年修仙传客户端代码仓库
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
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System;
 
namespace vnxbqy.UI
{
    public class ActStoreCell : MonoBehaviour
    {
        [SerializeField] ItemCell itemCell;
        [SerializeField] Text nameText;
        [SerializeField] Image moneyIcon;
        [SerializeField] Text moneyCntText;
        [SerializeField] Text buyLimitCountText;
        [SerializeField] Text buyConditionText;
        [SerializeField] Image sellImg;
        [SerializeField] Button shopCellBtn;
 
        StoreModel m_storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        BossTrialModel bossTrialModel { get { return ModelCenter.Instance.GetModel<BossTrialModel>(); } }
 
        public void SetDisplay(StoreConfig storeConfig, int recommendGoodId)
        {
            ItemConfig itemConfig = ItemConfig.Get(m_storeModel.GetReplaceId(storeConfig.ID, storeConfig.ItemID));
            if (itemConfig == null) return;
 
            ItemCellModel cellModel = new ItemCellModel(itemConfig.ID, false, (ulong)storeConfig.ItemCnt);
            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);
 
            int canBuyCnt = 0;
            int addBuyCnt = 0;
            bool isLimitBuy = BuyItemController.Instance.CheckIsLimitBuyCnt(storeConfig, out canBuyCnt, out addBuyCnt);
 
            BuyShopItemLimit shopItemLimit = m_storeModel.GetBuyShopLimit((uint)storeConfig.ID);
            int remainNum = canBuyCnt;
            if (shopItemLimit != null)
            {
                remainNum = canBuyCnt - shopItemLimit.BuyCnt;
            }
 
            
            //限制条件
            bool isCanBuy = m_storeModel.rankActStore_ActType == BossTrialModel.operaType ? bossTrialModel.submitAllCount >= storeConfig.LimitValue : true;
            buyConditionText.SetActive(!isCanBuy);
            moneyIcon.SetActive(isCanBuy);
            buyLimitCountText.SetActive(isCanBuy);
 
            if (isLimitBuy)
            {
                buyLimitCountText.SetActive(isCanBuy);
                buyLimitCountText.text = Language.Get("RechargeGiftActWin4", remainNum);
                sellImg.SetActive(remainNum == 0);
            }
            else
            {
                buyLimitCountText.SetActive(false);
                sellImg.SetActive(false);
            }
 
            buyConditionText.text = Language.Get("BossTrial10", storeConfig.LimitValue);
 
 
 
 
            if (storeConfig.ID == recommendGoodId)
            {
                DisplayRecommendEffect();
            }
            else
            {
                RecycleRecommendEffect();
            }
 
            shopCellBtn.RemoveAllListeners();
            shopCellBtn.AddListener(() =>
            {
                if (!isCanBuy)
                    return;
                m_storeModel.OnClickShopCell(storeConfig);
            });
        }
 
        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;
            }
        }
 
    }
}