少年修仙传客户端代码仓库
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, April 22, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
using System;
using System.Collections.Generic;
 
namespace vnxbqy.UI
{
 
    public class TipGetWaysWidget : MonoBehaviour
    {
        [SerializeField] ScrollRect m_ScrollRect;
        [SerializeField] CanvasGroup m_AlphaTween;
 
        string windowName;
        List<WayCell> getWayBehaviours = new List<WayCell>();
 
        [SerializeField] ItemBehaviour m_Item;
        [SerializeField] Text m_Money;
        [SerializeField] Button m_Buy;
        [SerializeField] RectTransform m_Widget_Buy;
 
        public void ShowItem()
        {
            if (m_Widget_Buy == null)
                return;
            var itemID = ItemTipUtility.mainTipData.itemId;
            var shopConfig = StoreConfig.GetStoreCfg(itemID, 2, 5);
            if (shopConfig == null)
            {
                m_Widget_Buy.SetActive(false);
                return;
            }
 
            int curVipIndex = -1;
            int nextVipIndex = -1;
            bool isVipBuy = BuyItemController.Instance.CheckIsVipBuy(shopConfig, out curVipIndex, out nextVipIndex);
 
            if ((isVipBuy && curVipIndex == -1) || PlayerDatas.Instance.baseData.LV < shopConfig.LV)
            {
                m_Widget_Buy.SetActive(false);
                return;
            }
 
            m_Widget_Buy.SetActive(true);
            m_Money.text = shopConfig.MoneyNumber.ToString();
            m_Item.SetItem(itemID, 1);
            m_Buy.RemoveAllListeners();
            m_Buy.AddListener(() =>
            {
                BuyItem(shopConfig.ID);
            });
        }
 
 
        private void BuyItem(int goodID)
        {
            ItemTipUtility.GoodOperate(ItemOperateType.buy, goodID, 1);
 
        }
        public void Display(ItemTipUtility.GetWay getWay)
        {
            CreateGetWayBehaviour(getWay.ways.Count);
            for (var i = 0; i < getWayBehaviours.Count; i++)
            {
                var behaviour = getWayBehaviours[i];
                if (i < getWay.ways.Count)
                {
                    var way = getWay.ways[i];
                    behaviour.SetActive(true);
                    behaviour.Display(getWay.itemId, way);
                    behaviour.RemoveAllListeners();
                    behaviour.AddListener(OnGetWay);
                }
                else
                {
                    behaviour.SetActive(false);
                }
            }
 
            m_ScrollRect.verticalNormalizedPosition = 1f;
            m_ScrollRect.AddMissingComponent<RayAccepter>();
            this.SetActive(true);
            m_AlphaTween.alpha = 0;
            m_AlphaTween.DOFade(1, 0.5f);
 
            ShowItem();
        }
 
        public void Bind(string windowName)
        {
            this.windowName = windowName;
        }
 
        private void OnGetWay()
        {
            if (!string.IsNullOrEmpty(windowName))
            {
                WindowCenter.Instance.Close(windowName);
            }
        }
 
        public void Hide()
        {
            m_AlphaTween.alpha = 1;
            m_AlphaTween.DOFade(0, 0.5f).OnComplete(() => { this.SetActive(false); });
        }
 
        private void CreateGetWayBehaviour(int count)
        {
            var nowCount = getWayBehaviours.Count;
            var need = count - nowCount;
            for (var i = 0; i < need; i++)
            {
                var instance = UIUtility.CreateWidget("GetWayCell", "GetWayCell");
 
                instance.transform.SetParentEx(m_ScrollRect.content, Vector3.zero, Quaternion.identity, Vector3.one);
                var getWellBehaviour = instance.GetComponent<WayCell>();
                getWayBehaviours.Add(getWellBehaviour);
            }
        }
 
    }
 
}