yyl
4 天以前 ceda2daaf5ceb25fcffa9d7e6693027add1a2eb6
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;
 
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 1:
                int shopID = int.Parse(way.CustomValue);
                if (StoreModel.Instance.CheckPopBuyWin(shopID))
                {
                    StoreModel.Instance.buyShopID = shopID;
                    UIManager.Instance.OpenWindow<BuyItemWin>();
                }
                break;
            case 0:
            default:
                if (WindowSearchConfig.HasKey(way.WinJumpID))
                {
                    var config = WindowSearchConfig.Get(way.WinJumpID);
                    if (config.WinName == "MainWin")
                    {
                        UIManager.Instance.GetUI<MainWin>()?.CloseSubUI();
                        UIManager.Instance.GetUI<MainWin>()?.ClickFunc(0);
                    }
                    else
                    {
                        if (!UIManager.Instance.IsOpened(config.WinName))
                        {
                            UIJumpManager.Instance.OpenWindow(way.WinJumpID);
                        }
                    }
                }
                break;
        }
 
        if (GuideConfig.HasKey(way.GuideID))
        {
            NewBieCenter.Instance.StartNewBieGuide(way.GuideID);
        }
 
    }
}