少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
using UnityEngine;
using UnityEngine.UI;
 
using System;
 
namespace Snxxz.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 _storeModel;
        StoreModel m_storeModel
        {
            get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); }
        }
        
        CrossServerOneVsOneModel crossServerModel { get { return ModelCenter.Instance.GetModel<CrossServerOneVsOneModel>(); } }
 
        public void SetDisplay(StoreConfig storeConfig)
        {
            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.gameObject.SetActive(false);
            if (!string.IsNullOrEmpty(storeConfig.SalesStatus))
            {
                stateImg.gameObject.SetActive(true);
                stateImg.SetSprite(storeConfig.SalesStatus);
                stateImg.SetNativeSize();
            }
            else
            {
                stateImg.gameObject.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.gameObject.SetActive(!isShowBuyPrice);
            refreshTimeText.gameObject.SetActive(false);
            moneyIcon.gameObject.SetActive(isShowBuyPrice);
            if (canBuyCnt > 0)
            {
                itemCell.countText.gameObject.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.gameObject.SetActive(false);
                    sellImg.gameObject.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.gameObject.SetActive(true);
                        refreshTimeText.text = refreshDes;
                    }
                }
            }
            else
            {
                itemCell.countText.gameObject.SetActive(false);
            }
          
            shopCellBtn.RemoveAllListeners();
            shopCellBtn.AddListener(()=>
            {
                m_storeModel.OnClickShopCell(storeConfig);
                crossServerModel.ClearRedpoint(storeConfig.ID);
            });
           
        }
 
        private void UpdateRefreshTime()
        {
            if (!sellImg.gameObject.activeInHierarchy) return;
            
 
        }
    }
}