少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
//--------------------------------------------------------
//    [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] RectTransform m_Container;
        [SerializeField] Text m_Category;
        [SerializeField] TaskFeedbackFunc[] m_Funcs;
 
        public static string funcTitle = string.Empty;
 
        public static event Action<int> onSelectTask;
 
        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();
            WindowCenter.Instance.windowAfterCloseEvent += WindowAfterCloseEvent;
        }
 
        protected override void OnActived()
        {
            base.OnActived();
            var localpos = transform.InverseTransformPoint(TaskFeedbackModel.s_ClickPosition);
            m_Container.localPosition = m_Container.localPosition.SetY(localpos.y);
        }
 
        protected override void OnAfterOpen()
        {
        }
 
        protected override void OnPreClose()
        {
            WindowCenter.Instance.windowAfterCloseEvent -= WindowAfterCloseEvent;
        }
 
        protected override void OnAfterClose()
        {
        }
        #endregion
 
        void Display()
        {
            m_Category.text = funcTitle;
            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;
                        }
                        if (config.type == 4)
                        {
                            if (onSelectTask != null)
                            {
                                onSelectTask(config.condition);
                            }
                        }
                        switch ((GuideType)guideConfig.Type)
                        {
                            case GuideType.Functional:
                                RemoveExistUnderwayGuides();
                                NewBieCenter.Instance.ResetGuide(config.guide);
                                FunctionalGuideCenter.Instance.StartGuide(config.guide);
                                break;
                            default:
                                NewBieCenter.Instance.StartNewBieGuide(config.guide);
                                break;
                        }
                    }
                }
            }
        }
 
        void RemoveExistUnderwayGuides()
        {
            foreach (var func in model.taskFeedbackFuncs)
            {
                var config = TaskFeedbackFuncConfig.Get(func);
                if (config != null && config.guide != 0)
                {
                    var guideConfig = GuideConfig.Get(config.guide);
                    if (guideConfig != null && guideConfig.Type == (int)GuideType.Functional)
                    {
                        if (FunctionalGuideCenter.Instance.ExistUnderwayGuide(config.guide))
                        {
                            FunctionalGuideCenter.Instance.RemoveGuide(config.guide);
                        }
                    }
                }
            }
        }
 
        private void WindowAfterCloseEvent(Window win)
        {
            if (win is MainInterfaceWin)
            {
                CloseImmediately();
            }
        }
 
        [Serializable]
        public struct TaskFeedbackFunc
        {
            public Button button;
            public Text label;
        }
    }
 
}