lcy
6 天以前 cc349a454d938e4046151233d6639d2c3807da9b
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
 
using UnityEngine;
using UnityEngine.UI;
 
public class ItemTipWayWin : UIBase
{
    [SerializeField] ItemCell itemCell;
    [SerializeField] Text nameText;
    [SerializeField] Text descText;
    [SerializeField] ScrollerController scroller;
 
    int itemID;
 
 
 
    protected override void OnPreOpen()
    {
        scroller.OnRefreshCell += OnRefreshCell;
        itemID = functionOrder;
 
        itemCell.Init(new ItemCellModel(itemID, false, 0));
        var itemConfig = ItemConfig.Get(itemID);
        nameText.text = itemConfig.ItemName;
        descText.text = itemConfig.Description;
 
        CreateScroller();
    }
 
    protected override void OnPreClose()
    {
        scroller.OnRefreshCell -= OnRefreshCell;
    }
 
    void CreateScroller()
    {
        var itemConfig = ItemConfig.Get(itemID);
        scroller.Refresh();
        for (int i = 0; i < itemConfig.GetWay.Length; i++)
        {
            scroller.AddCell(ScrollerDataType.Header, itemConfig.GetWay[i]);
        }
        scroller.Restart();
    }
 
 
    void OnRefreshCell(ScrollerDataType type, CellView cell)
    {
        var way = GetItemWaysConfig.Get(cell.index);
        var nameText = cell.FindComponent("Text", "name") as Text;
        nameText.text = way.Name;
 
        var descText = cell.FindComponent("Text", "way") as Text;
        descText.text = way.Text;
 
        cell.GetComponent<Button>().AddListener(() =>
        {
            Run(way);
        });
    }
 
    void Run(GetItemWaysConfig way)
    {
        if (way == null)
            return;
        int funcID = way.FuncID;
        if (FuncOpenLVConfig.HasKey(funcID) && !FuncOpen.Instance.IsFuncOpen(funcID))
            return;
        switch (way.Type)
        {
            case 0:
                if (WindowSearchConfig.HasKey(way.WinJumpID))
                {
                    UIJumpManager.Instance.OpenWindow(way.WinJumpID);
                }
                break;
            case 1:
                int shopID = int.Parse(way.CustomValue);
                if (StoreModel.Instance.CheckPopBuyWin(shopID))
                {
                    StoreModel.Instance.buyShopID = shopID;
                    UIManager.Instance.OpenWindow<BuyItemWin>();
                }
                break;
            default:
                if (WindowSearchConfig.HasKey(way.WinJumpID))
                {
                    UIJumpManager.Instance.OpenWindow(way.WinJumpID);
                }
                break;
        }
 
    }
}