少年修仙传客户端代码仓库
client_Zxw
2018-09-11 639aaa1e2ee1fc1a8876ddc242f5e21f8f1d4e74
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, September 11, 2018
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TableConfig;
namespace Snxxz.UI
{
    //功能预告面板
    public class FeatureNoticeWin : Window
    {
        [SerializeField] Text m_TextAdvanceName;//功能名
        [SerializeField] Image m_FeaturesImage;//功能图标
        [SerializeField] Text m_Text_ShowA;//显示内容1
        [SerializeField] Text m_TextShowB;//显示内容2
        [SerializeField] Text m_TextShowC;//显示内容3
        [SerializeField] Text m_TextShowD;//显示内容4
        [SerializeField] ScrollerController m_ScrollerController;
        [SerializeField] Button m_CloseButton;
        List<FunctionForecastConfig> FunctionList = new List<FunctionForecastConfig>();
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseButton.AddListener(()=> { Close(); });
        }
 
        protected override void OnPreOpen()
        {
            AddList();
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;
            OnCreateGridLineCell(m_ScrollerController);
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
        }
 
        void OnCreateGridLineCell(ScrollerController gridCtrl)
        {
            gridCtrl.Refresh();
            for (int i = 0; i < FunctionList.Count; i++)
            {
                if (i == 0)
                {
                    gridCtrl.AddCell(ScrollerDataType.Header, FunctionList[i].FuncId);
                }
                else
                {
                    gridCtrl.AddCell(ScrollerDataType.Normal, FunctionList[i].FuncId);
                }
            }
            gridCtrl.Restart();
        }
        private void OnRefreshGridCell(ScrollerDataType type, CellView cell)
        {
            int funcId = cell.index;
            if (type == ScrollerDataType.Header)
            {
                FeaturesType1 featuresType1 = cell.GetComponent<FeaturesType1>();
                featuresType1.GetTheFeatureID(funcId);
            }
            else if (type == ScrollerDataType.Normal)
            {
                FeaturesType2 featuresType2 = cell.GetComponent<FeaturesType2>();
                featuresType2.GetTheFeatureID(funcId);
            }
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
        private void AddList()
        {
            if (FunctionList.Count <= 0)
            {
                var configs = Config.Instance.GetAllKeys<FunctionForecastConfig>();
                foreach (var key in configs)
                {
                    var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(key);
                    if (functionForecastConfig != null && functionForecastConfig.Display == 1)
                    {
                        FunctionList.Add(functionForecastConfig);
                    }
 
                }
            }
        }
    }
 
}