少年修仙传客户端代码仓库
client_Zxw
2018-09-12 259af9624cb7f4735e0efbc85f78d7ddffec6b36
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
//--------------------------------------------------------
//    [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 enum FeatureNoticeEnum
    {
        Pet=6,//灵宠
        Horse=8,//坐骑
        Wing=97,//翅膀
        GossipFurnace=87,//八卦炉
    }
 
    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;
        [SerializeField] Text m_TextTurnedOn;//已开启
        [SerializeField] Text m_TextUnopened;//未开启
        [SerializeField] Text m_Textschedule;//进度
        [SerializeField] Button m_ButtonGoto;
        [SerializeField] RawImage m_RawImage1;
        [SerializeField] RawImage m_RawImage2;
        [SerializeField] RawImage m_RawImage3;
        [SerializeField] RawImage m_RawImage4;
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        FeatureNoticeModel featureNoticeModel { get { return ModelCenter.Instance.GetModel<FeatureNoticeModel>(); } }
        #region Built-in
        private int ClickFuncID = 0;
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            m_CloseButton.AddListener(()=> { Close(); });
        }
 
        protected override void OnPreOpen()
        {
            DefaultSelection();//获取默认选择
            m_ScrollerController.OnRefreshCell += OnRefreshGridCell;       
            OnCreateGridLineCell(m_ScrollerController);
            ContentDisplay();
            m_ScrollerController.JumpIndex(JumpIndex());
        }
 
        protected override void OnAfterOpen()
        {
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += OnPlayersUpLV;
            treasureModel.treasureStateChangeEvent += treasureStateChangeEvent;
            treasureModel.treasureStageUpEvent += treasureStageUpEvent;
        }
        protected override void OnPreClose()
        {
            UI3DModelExhibition.Instance.StopShowNPC();
            UI3DModelExhibition.Instance.StopShowHourse();
            UI3DModelExhibition.Instance.StopShowWing();
            UI3DTreasureExhibition.Instance.StopShow();
        }
        protected override void OnAfterClose()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent -= OnPlayersUpLV;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
            m_ScrollerController.OnRefreshCell -= OnRefreshGridCell;
            treasureModel.treasureStateChangeEvent -= treasureStateChangeEvent;
            treasureModel.treasureStageUpEvent -= treasureStageUpEvent;
            if (featureNoticeModel.redPointStre1.state == RedPointState.Simple)
            {
                featureNoticeModel.redPointStre1.state = RedPointState.None;
            }
            
        }
        private void treasureStageUpEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        private void treasureStateChangeEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
 
        private void OnFuncStateChangeEvent(int obj)
        {
            ContentDisplay();
            m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
        }
        private void OnPlayersUpLV(PlayerDataRefresh obj)
        {
            if (obj == PlayerDataRefresh.LV)
            {
                ContentDisplay();
                m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
            }
        }
        void OnCreateGridLineCell(ScrollerController gridCtrl)
        {
            gridCtrl.Refresh();
            for (int i = 0; i < featureNoticeModel.FunctionList.Count; i++)
            {
                if (i == 0)
                {
                    gridCtrl.AddCell(ScrollerDataType.Header, featureNoticeModel.FunctionList[i].FuncId);
                }
                else
                {
                    gridCtrl.AddCell(ScrollerDataType.Normal, featureNoticeModel.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);
                if (funcId == ClickFuncID)
                {
                    featuresType1.ImageSelected.SetActive(true);
                }
                else
                {
                    featuresType1.ImageSelected.SetActive(false);
                }
                featuresType1.Button.SetListener(()=> 
                {
                    if (funcId != ClickFuncID)
                    {
                        ClickFuncID = funcId;
                        ContentDisplay();
                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
                    }
                });
            }
            else if (type == ScrollerDataType.Normal)
            {
                FeaturesType2 featuresType2 = cell.GetComponent<FeaturesType2>();
                featuresType2.GetTheFeatureID(funcId);
                if (funcId == ClickFuncID)
                {
                    featuresType2.ImageSelected.SetActive(true);
                }
                else
                {
                    featuresType2.ImageSelected.SetActive(false);
                }
                featuresType2.Button.SetListener(() =>
                {
                    if (funcId != ClickFuncID)
                    {
                        ClickFuncID = funcId;
                        ContentDisplay();
                        m_ScrollerController.m_Scorller.RefreshActiveCellViews();//刷新可见
                    }
                });
            }
        }
 
      
        #endregion
        private void DefaultSelection()//获取默认选择
        {
            var configs = Config.Instance.GetAllValues<FunctionForecastConfig>();
            foreach (var config in configs)
            {
                int openTag = config.FuncId;
                if (!FuncOpen.Instance.IsFuncOpen(openTag))
                {
                    ClickFuncID = openTag;
                    return;
                }
            }
            if (ClickFuncID == 0)
            {
                ClickFuncID = featureNoticeModel.FunctionList[0].FuncId;
            }
        }
 
        private int JumpIndex()//Jump选中
        {
            int Index = 0;
            Index = featureNoticeModel.FunctionList.FindIndex((x)=> 
            {
                return x.FuncId == ClickFuncID;
            });
            return Index;
        }
 
        private void ContentDisplay()//内容显示
        {
            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
            if (functionForecastConfig == null)
            {
                return;
            }
            m_TextAdvanceName.text = functionForecastConfig.FuncName;
            DisplayIcon(ClickFuncID);
            string[] StrList = ConfigParse.GetMultipleStr(functionForecastConfig.Content);
            if (StrList.Length > 0)
            {
                m_Text_ShowA.text = StrList[0];
                m_TextShowB.text = StrList[1];
                m_TextShowC.text = StrList[2];
                m_TextShowD.text = StrList[3];
            }
            if (FuncOpen.Instance.IsFuncOpen(ClickFuncID))
            {
                m_TextTurnedOn.gameObject.SetActive(true);
                m_TextUnopened.gameObject.SetActive(false);
                m_Textschedule.gameObject.SetActive(false);
                m_ButtonGoto.gameObject.SetActive(false);
            }
            else
            {
                TrailerClassification(ClickFuncID);
            }
        }
 
        private void DisplayIcon(int funcID)//显示图标或者模型
        {
            m_RawImage1.gameObject.SetActive(false);
            m_RawImage2.gameObject.SetActive(false);
            m_RawImage3.gameObject.SetActive(false);
            m_RawImage4.gameObject.SetActive(false);
            m_FeaturesImage.gameObject.SetActive(false);
            var functionForecastConfig = Config.Instance.Get<FunctionForecastConfig>(ClickFuncID);
            switch (funcID)
            {
                case (int)FeatureNoticeEnum.Pet:
                    UI3DModelExhibition.Instance.StopShowHourse();
                    UI3DModelExhibition.Instance.StopShowWing();
                    UI3DTreasureExhibition.Instance.StopShow();
                    m_RawImage1.gameObject.SetActive(true);
                    var npcConfig = Config.Instance.Get<NPCConfig>(50106001);
                    UI3DModelExhibition.Instance.BeginShowNPC(50106001, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_RawImage1);
                    break;
                case (int)FeatureNoticeEnum.Horse:
                    UI3DModelExhibition.Instance.StopShowNPC();
                    UI3DModelExhibition.Instance.StopShowWing();
                    UI3DTreasureExhibition.Instance.StopShow();
                    m_RawImage2.gameObject.SetActive(true);
                    HorseConfig _model = Config.Instance.Get<HorseConfig>(100);
                    UI3DModelExhibition.Instance.BeginShowHourse(_model.Model, m_RawImage2);
                    break;
                case (int)FeatureNoticeEnum.Wing:
                    UI3DModelExhibition.Instance.StopShowNPC();
                    UI3DModelExhibition.Instance.StopShowHourse();
                    UI3DTreasureExhibition.Instance.StopShow();
                    m_RawImage3.gameObject.SetActive(true);
                    var vec3 = new Vector3(0,90,-90);
                    int job = PlayerDatas.Instance.baseData.Job;
                    if (job == 1)
                    {
                        var config = Config.Instance.Get<WingRefineExpConfig>(3711);
                        int _modelID = config.Model;
                        UI3DModelExhibition.Instance.BeginShowWing(_modelID, vec3, m_RawImage3);
                    }
                    else if (job == 1)
                    {
                        var config = Config.Instance.Get<WingRefineExpConfig>(3721);
                        int _modelID = config.Model;
                        UI3DModelExhibition.Instance.BeginShowWing(_modelID, vec3, m_RawImage3);
                    }
                    break;
                case (int)FeatureNoticeEnum.GossipFurnace:
                    UI3DModelExhibition.Instance.StopShowNPC();
                    UI3DModelExhibition.Instance.StopShowHourse();
                    UI3DModelExhibition.Instance.StopShowWing();
                    m_RawImage4.gameObject.SetActive(true);
                    UI3DTreasureExhibition.Instance.BeginShowTreasure(301, m_RawImage4);
                    break;
                default:
                    m_FeaturesImage.gameObject.SetActive(true);
                    m_FeaturesImage.SetSprite(functionForecastConfig.Icon);
                    break;
 
            }
        }
        void TrailerClassification(int funcID)//预告分类
        {
            m_TextTurnedOn.gameObject.SetActive(false);
            m_TextUnopened.gameObject.SetActive(false);
            m_Textschedule.gameObject.SetActive(false);
            m_ButtonGoto.gameObject.SetActive(false);
            FuncOpenLVConfig funcoPenConfig = Config.Instance.Get<FuncOpenLVConfig>(funcID);
            if (funcoPenConfig.LimitMagicWeapon != 0 || funcoPenConfig.LimitMissionID != 0)
            {
                if (funcoPenConfig.LimitMagicWeapon != 0)//法宝
                {
                    int faBaoID = funcoPenConfig.LimitMagicWeapon / 100;
                    MagicWeapon(faBaoID);
 
                }
                else if (funcoPenConfig.LimitMissionID != 0)//任务
                {
                    m_TextUnopened.gameObject.SetActive(true);
                    m_TextUnopened.text= string.Format(Language.Get("TaskFuncOpen"), funcoPenConfig.LimitLV);
                    return;
                }
            }
            else//等级
            {
                m_TextUnopened.gameObject.SetActive(true);
                m_TextUnopened.text= string.Format(Language.Get("FuncLevelOpen"), funcoPenConfig.LimitLV);
                return;
            }
        }
 
        private void MagicWeapon(int fabaoID)
        {
            m_Textschedule.gameObject.SetActive(true);
            m_ButtonGoto.gameObject.SetActive(true);
            Treasure treasure;
            TreasureConfig _treasure = Config.Instance.Get<TreasureConfig>(fabaoID);
            m_ButtonGoto.SetListener(()=> 
            {
                var config = Config.Instance.Get<TreasureConfig>(fabaoID);
                treasureModel.selectedTreasure = fabaoID;
                treasureModel.currentCategory = (TreasureCategory)config.Category;
                WindowJumpMgr.Instance.WindowJumpTo(JumpUIType.TreasureCollectSoul);
            });
            if (treasureModel.TryGetTreasure(fabaoID, out treasure)
                && treasure.state == TreasureState.Collected)
            {            
                var list = treasure.treasureStages;
                var funcStage = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i].unlockType == TreasureStageUnlock.Func &&
                        list[i].func == ClickFuncID)
                    {
                        funcStage = i;
                        break;
                    }
                }
                if (treasure.stage < funcStage)
                {
                    if (treasure.stage == funcStage - 1 || funcStage == 0)
                    {
                        if (treasure.exp >= treasure.treasureStages[funcStage].exp)
                        {
                            m_Textschedule.text = "100%";
                        }
                        else
                        {
                            string str = ((float)treasure.exp / treasure.treasureStages[funcStage].exp) * 100 + "%";
                            m_Textschedule.text = string.Format(Language.Get("YGYouFB"), str);
                        }                       
                    }
                    else
                    {
                        m_Textschedule.text = 0+" %";
                    }
                }
            }
            else
            {
                m_Textschedule.text = string.Format(Language.Get("YGNoFB"), _treasure.Name);
            }
        }
    }
 
}