少年修仙传客户端代码仓库
client_Hale
2019-05-22 a76cedaf8e3a2ded5f2f2b237a85e564a4a489c6
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Thursday, May 16, 2019
//--------------------------------------------------------
 
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
 
namespace Snxxz.UI
{
 
    public class TaskFeedbackFuncWin : Window
    {
        [SerializeField] TaskFeedbackFunc[] m_Funcs;
 
        TaskFeedbackModel model { get { return ModelCenter.Instance.GetModel<TaskFeedbackModel>(); } }
        #region Built-in
        protected override void BindController()
        {
        }
 
        protected override void AddListeners()
        {
            for (int i = 0; i < m_Funcs.Length; i++)
            {
                var index = i;
                m_Funcs[i].button.AddListener(() =>
                {
                    OnFunc(index);
                });
            }
        }
 
        protected override void OnPreOpen()
        {
            Display();
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void Display()
        {
            for (int i = 0; i < m_Funcs.Length; i++)
            {
                m_Funcs[i].button.gameObject.SetActive(i < model.taskFeedbackFuncs.Count);
                if (i < model.taskFeedbackFuncs.Count)
                {
                    var config = TaskFeedbackFuncConfig.Get(model.taskFeedbackFuncs[i]);
                    if (config != null)
                    {
                        m_Funcs[i].label.text = config.name;
                    }
                }
            }
        }
 
        private void OnFunc(int index)
        {
            CloseImmediately();
            if (index < model.taskFeedbackFuncs.Count)
            {
                var config = TaskFeedbackFuncConfig.Get(model.taskFeedbackFuncs[index]);
                if (config != null)
                {
                    if (config.jump != 0)
                    {
                        WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.jump);
                    }
                    else if (config.guide != 0)
                    {
                        var guideConfig = GuideConfig.Get(config.guide);
                        if (guideConfig == null)
                        {
                            DebugEx.LogFormat("引导<color=#ff0000>{0}</color>未添加", config.guide);
                            return;
                        }
                        switch ((GuideType)guideConfig.Type)
                        {
                            case GuideType.Functional:
                                FunctionalGuideCenter.Instance.StartGuide(config.guide);
                                break;
                            default:
                                NewBieCenter.Instance.StartNewBieGuide(config.guide);
                                break;
                        }
                    }
                }
            }
        }
 
        [Serializable]
        public struct TaskFeedbackFunc
        {
            public Button button;
            public Text label;
        }
    }
 
}