少年修仙传客户端代码仓库
lcy
2024-12-16 a39c35fc6449430cd02bccb681c4a0a880e46cd9
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
    public class RoleTitle : Window, SecondWindowInterface
    {
        [SerializeField] Button m_GetTitleBtn;
        [SerializeField] Button m_ActivityTitleBtn;
        [SerializeField] Button m_VipTitleBtn;
        [SerializeField] Button m_AchieveTitleBtn;
        [SerializeField] ScrollerController m_Controller;
        [SerializeField] Button m_TitlePropertyBtn;
        [SerializeField] Text m_TitleTip;
        private TitleType presentType = TitleType.None;
 
        TitleModel m_TitleModel;
        TitleModel model
        {
            get
            {
                return m_TitleModel ?? (m_TitleModel = ModelCenter.Instance.GetModel<TitleModel>());
            }
        }
 
        public Button close { get; set; }
 
        private void OnTitlePropertyClick()
        {
            WindowCenter.Instance.Open<TitleTotalGetWin>();
        }
 
        private void OnRefreshGainTitle()
        {
            switch (presentType)
            {
                case TitleType.Get:
                    OnIsGetTitle();
                    break;
                case TitleType.Activity:
                case TitleType.Vip:
                case TitleType.Achivement:
                    m_Controller.m_Scorller.RefreshActiveCellViews();
                    break;
            }
 
        }
 
        void OnIsGetTitle()
        {
            presentType = TitleType.Get;
 
            model.roleTitleList.Clear();
            var _dict = model.GetAllGainTitle();
            foreach (var _titleId in _dict.Keys)
            {
                if (model.IsTitleGain(_titleId))
                {
                    model.roleTitleList.Add(_titleId);
                }
            }
            m_TitleTip.SetActive(model.roleTitleList.Count < 1);
            OnRefreshScroller();
 
            SetTitleSelect(presentType);
        }
 
        private void SetTitleSelect(TitleType type)
        {
            m_GetTitleBtn.image.SetSprite("Title_TabDark");
            m_VipTitleBtn.image.SetSprite("Title_TabDark");
            m_AchieveTitleBtn.image.SetSprite("Title_TabDark");
            m_ActivityTitleBtn.image.SetSprite("Title_TabDark");
            switch (type)
            {
                case TitleType.Get:
                    m_GetTitleBtn.image.SetSprite("Title_TabRight");
                    break;
                case TitleType.Activity:
                    m_ActivityTitleBtn.image.SetSprite("Title_TabRight");
                    break;
                case TitleType.Vip:
                    m_VipTitleBtn.image.SetSprite("Title_TabRight");
                    break;
                case TitleType.Achivement:
                    m_AchieveTitleBtn.image.SetSprite("Title_TabRight");
                    break;
            }
        }
 
        void OnTitle(TitleType type)
        {
            if (presentType == type)
            {
                return;
            }
            model.roleTitleList.Clear();
            m_TitleTip.SetActive(false);
            List<DienstgradConfig> _list = DienstgradConfig.GetTitlesByType(type);
            if (_list != null)
            {
                foreach (DienstgradConfig cfg in _list)
                {
                    model.roleTitleList.Add(cfg.ID);
                }
            }
            OnRefreshScroller();
 
            presentType = type;
            SetTitleSelect(presentType);
        }
 
        void OnRefreshScroller()
        {
            model.roleTitleList.Sort(Compare);
            if (model.roleTitleList.Count > 0)
            {
                model.presentSelectTitle = model.roleTitleList[0];
            }
            m_Controller.Refresh();
            for (int i = 0; i < model.roleTitleList.Count; i++)
            {
                m_Controller.AddCell(ScrollerDataType.Normal, i, OnTitleItemClick);
            }
            m_Controller.Restart();
        }
 
        void OnTitleItemClick(CellView cell)
        {
            int index = cell.index;
            if (index < model.roleTitleList.Count)
            {
                model.presentSelectTitle = model.roleTitleList[index];
                WindowCenter.Instance.Open<TitleDetailsWin>();
                m_Controller.m_Scorller.RefreshActiveCellViews();
            }
        }
 
        private int Compare(int x, int y)
        {
            bool newget_x = model.IsNewGet(x);
            bool newget_y = model.IsNewGet(y);
            if (newget_x.CompareTo(newget_y) != 0)
            {
                return -newget_x.CompareTo(newget_y);
            }
 
            bool isRed_x = model.IsStarRedpoint(x);
            bool isRed_y = model.IsStarRedpoint(y);
            if (isRed_x.CompareTo(isRed_y) != 0)
            {
                return -isRed_x.CompareTo(isRed_y);
            }
 
            bool isGetx = model.IsTitleGain(x);
            bool isGety = model.IsTitleGain(y);
            if (isGetx.CompareTo(isGety) != 0)
            {
                return -isGetx.CompareTo(isGety);
            }
            var config_x = DienstgradConfig.Get(x);
            var config_y = DienstgradConfig.Get(y);
            if (config_x != null && config_y != null
                && config_x.order != config_y.order)
            {
                return config_x.order.CompareTo(config_y.order);
            }
            return 0;
        }
 
 
        protected override void BindController()
        {
            if (this is SecondWindowInterface)
            {
                var frame = this.GetComponentInChildren<SecondFrameLoader>();
                frame.Create();
                close = frame.GetComponentInChildren<Button>();
            }
        }
 
        protected override void AddListeners()
        {
            m_TitlePropertyBtn.onClick.AddListener(OnTitlePropertyClick);
            m_GetTitleBtn.onClick.AddListener(OnIsGetTitle);
            m_ActivityTitleBtn.onClick.AddListener(() => { OnTitle(TitleType.Activity); });
            m_VipTitleBtn.onClick.AddListener(() => { OnTitle(TitleType.Vip); });
            m_AchieveTitleBtn.onClick.AddListener(() => { OnTitle(TitleType.Achivement); });
            close.onClick.AddListener(CloseClick);
            m_Controller.lockType = EnhanceLockType.KeepVertical;
        }
 
        protected override void OnPreOpen()
        {
            model.OnRefreshGainTitle += OnRefreshGainTitle;
            //C0335_tagCPlayerDienstgradRefresh titlePack = new C0335_tagCPlayerDienstgradRefresh();
            //GameNetSystem.Instance.SendInfo(titlePack);
            OnIsGetTitle();
            m_Controller.JumpIndex(0);
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
            presentType = TitleType.None;
            model.OnRefreshGainTitle -= OnRefreshGainTitle;
            model.SetTitlesGet();
        }
    }
}