少年修仙传客户端代码仓库
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
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using System;
 
namespace vnxbqy.UI
{
    public class MysticalQGSaleItem : MonoBehaviour
    {
        [SerializeField] Text originalPrice;
        [SerializeField] Image originalMoneyIcon;
        [SerializeField] Text presentPrice;
        [SerializeField] Image presentMoneyIcon;
        [SerializeField] Button buybtn;
        [SerializeField] Text saleTime;
        [SerializeField] Text zheText;
        [SerializeField] List<CommonItemBaisc> itemBaiscs = new List<CommonItemBaisc>();
 
        MysticalQGModel.MysticalShop mysticalShop = null;
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        
        MysticalQGModel qgModel { get { return ModelCenter.Instance.GetModel<MysticalQGModel>(); } }
 
        private void Awake()
        {
            buybtn.AddListener(ClickBuy);
        }
 
        private void OnEnable()
        {
            GlobalTimeEvent.Instance.secondEvent += UpdateSecond;
        }
 
        private void OnDisable()
        {
            GlobalTimeEvent.Instance.secondEvent -= UpdateSecond;
        }
 
        public void SetDisplay(MysticalQGModel.MysticalShop _mysticalShop)
        {
            this.mysticalShop = _mysticalShop;
            originalPrice.text = mysticalShop.storeConfig.MoneyOriginal.ToString();
            presentPrice.text = mysticalShop.storeConfig.MoneyNumber.ToString();
            originalMoneyIcon.SetIconWithMoneyType(mysticalShop.storeConfig.MoneyType);
            presentMoneyIcon.SetIconWithMoneyType(mysticalShop.storeConfig.MoneyType);
            int remianTime = mysticalShop.GetRemainSellTime();
            saleTime.text = Language.Get("MysticalQG101", TimeUtility.SecondsToHMS(remianTime));
            float zhe = ((float)mysticalShop.storeConfig.MoneyNumber / mysticalShop.storeConfig.MoneyOriginal) * 10;
            zheText.text = Language.Get("MysticalQG102", (float)Math.Round(zhe, 1));
            var items = storeModel.GetShopItemlistByIndex(mysticalShop.storeConfig);
            for(int i = 0; i < itemBaiscs.Count; i++)
            {
                var itemBaisc = itemBaiscs[i];
                if(i < items.Count)
                {
                    var itemInfo = items[i];
                    itemBaisc.SetActive(true);
                    ItemCellModel cellModel = new ItemCellModel(itemInfo.itemId,false, (ulong)itemInfo.count);
                    itemBaisc.Init(cellModel);
                    itemBaisc.button.RemoveAllListeners();
                    itemBaisc.button.AddListener(()=>
                    {
                        ItemTipUtility.Show(itemInfo.itemId);
                    });
                }
                else
                {
                    itemBaisc.SetActive(false);
                }
            }
        }
 
 
        private void UpdateSecond()
        {
            if (mysticalShop == null) return;
 
            int remianTime = mysticalShop.GetRemainSellTime();
            saleTime.text = Language.Get("MysticalQG101", TimeUtility.SecondsToHMS(remianTime));
            if (remianTime <= 0)
            {
                qgModel.UpdateSellTimeEnd();
            }
        }
 
        private void ClickBuy()
        {
            if (mysticalShop == null) return;
            ConfirmCancel.ShowPopConfirm(Language.Get("Mail101"), Language.Get("MysticalQG104", mysticalShop.storeConfig.MoneyNumber)
                , (bool isOk) =>
                 {
                     if (isOk)
                     {
                         if(mysticalShop.GetRemainSellTime() > 0)
                         {
                             storeModel.SendBuyShopItem(this.mysticalShop.storeConfig, 1);
                         }
                         else
                         {
                            ServerTipDetails.DisplayNormalTip(Language.Get("MysticalQG105"));
                         }
                     }
                 });
 
        }
    }
}