少年修仙传客户端代码仓库
client_linchunjie
2018-08-23 522ca3468a56c88cb15eaa428eb7499d3dba386f
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
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
    public class GetWaysWin : Window
    {
        [SerializeField]
        private ScrollerController _waysCtrl;
        [SerializeField]
        private Transform waysLineCell;
 
        [SerializeField]
        private Button _closeBtn;
 
        GetItemPathModel _itemPathModel;
        GetItemPathModel itemPathModel
        {
            get
            {
                return _itemPathModel ?? (_itemPathModel = ModelCenter.Instance.GetModel<GetItemPathModel>());
            }
        }
 
        DailyQuestModel _questModel;
        DailyQuestModel QuestModel
        {
            get { return _questModel ?? (_questModel = ModelCenter.Instance.GetModel<DailyQuestModel>()); }
        }
 
        protected override void BindController()
        {
            _waysCtrl.OnRefreshCell += RefreshWayCell;
        }
 
        protected override void AddListeners()
        {
            _closeBtn.onClick.AddListener(CloseWin);
        }
 
        protected override void OnPreOpen()
        {
            CreateWayCell();
        }
 
        protected override void OnAfterOpen()
        {
            transform.SetAsLastSibling();
        }
 
        protected override void OnPreClose()
        {
 
        }
 
        protected override void OnAfterClose()
        {
 
        }
 
        private List<GetItemWaysConfig> getWayslist;
        private void CreateWayCell()
        {
            getWayslist = itemPathModel.GetWaysList();
            _waysCtrl.Refresh();
            int i = 0;
            int remain = getWayslist.Count % waysLineCell.childCount;
            int line = (int)getWayslist.Count / waysLineCell.childCount;
            if (remain > 0)
            {
                line += 1;
            }
 
            for (i = 0; i < line; i++)
            {
                _waysCtrl.AddCell(ScrollerDataType.Header, i);
            }
            _waysCtrl.Restart();
        }
 
        private void RefreshWayCell(ScrollerDataType type, CellView cell)
        {
            int i = 0;
            for (i = 0; i < cell.transform.childCount; i++)
            {
                WayCell wayCell = cell.transform.GetChild(i).GetComponent<WayCell>();
                if (wayCell == null)
                    wayCell = cell.transform.GetChild(i).gameObject.AddComponent<WayCell>();
 
                int index = (cell.transform.childCount) * cell.index + i;
                if (index <= getWayslist.Count - 1)
                {
                    cell.transform.GetChild(i).gameObject.SetActive(true);
                    GetItemWaysConfig itemWaysModel = getWayslist[index];
                    wayCell.icon.SetSprite(itemWaysModel.Icon);
                    wayCell.wayName.text = itemWaysModel.Text;
                    wayCell.funcName.text = itemWaysModel.name;
                    wayCell.wayButton.RemoveAllListeners();
                    wayCell.wayButton.AddListener(() => {
                        ClickWayCell(itemWaysModel);
                    });
                }
                else
                {
                    cell.transform.GetChild(i).gameObject.SetActive(false);
                }
            }
        }
 
        public void ClickWayCell(GetItemWaysConfig itemWaysModel)
        {
            if (!string.IsNullOrEmpty(itemWaysModel.SelectActive) && itemWaysModel.SelectActive != "")
            {
                QuestModel.currentDailyQuest = int.Parse(itemWaysModel.SelectActive);
            }
            CloseImmediately();
            WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)itemWaysModel.OpenpanelId);
        }
 
        private void CloseWin()
        {
            itemPathModel.ResetAllModel();
            Close();
        }
 
    }
}