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
131
132
133
134
135
136
137
 
using System;
using System.Collections.Generic;
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;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        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;
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
    }
 
    private void OnFuncStateChangeEvent(int obj)
    {
        CreateScroller();
    }
 
    List<int> GetWayList()
    {
        var itemConfig = ItemConfig.Get(itemID);
        if (itemConfig.GetWay.IsNullOrEmpty())
            return new List<int>();
        List<int> resList = new List<int>();
        for (int i = 0; i < itemConfig.GetWay.Length; i++)
        {
            int way = itemConfig.GetWay[i];
            if (!GetItemWaysConfig.HasKey(way))
                continue;
            GetItemWaysConfig config = GetItemWaysConfig.Get(way);
            int funcID = config.FuncID;
            if (FuncOpenLVConfig.HasKey(funcID) && !FuncOpen.Instance.IsFuncOpen(funcID))
                continue;
            resList.Add(way);
        }
        return resList;
    }
 
    void CreateScroller()
    {
        var itemConfig = ItemConfig.Get(itemID);
        scroller.Refresh();
        List<int> wayList = GetWayList();
        for (int i = 0; i < wayList.Count; 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);
        }
 
    }
}