少年修仙传客户端代码仓库
hch
2025-06-12 204ef05a831c9484e2abc561d27ecbff7c797453
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Monday, November 27, 2017
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
 
namespace vnxbqy.UI
{
 
    public class FunctionalGuideTrigger : MonoBehaviour
    {
        [SerializeField] int[] guides;
 
        RectTransform container;
        Dictionary<int, FunctionalGuideBehaviour> behaviours = new Dictionary<int, FunctionalGuideBehaviour>();
 
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
        AchievementModel achievementModel { get { return ModelCenter.Instance.GetModel<AchievementModel>(); } }
        TaskModel taskModel { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
 
        Window m_Parent;
        Window parent { get { return m_Parent ?? (m_Parent = this.transform.GetComponentInParent<Window>()); } }
 
        private void Awake()
        {
            WindowCenter.Instance.windowAfterOpenEvent += OnWindowOpen;
            WindowCenter.Instance.windowBeforeCloseEvent += OnWindowPreClose;
 
            var instance = new GameObject("FunctionalGuideContainer");
            container = instance.AddMissingComponent<RectTransform>();
            container.MatchWhith(parent.transform as RectTransform);
        }
 
        private void OnDestroy()
        {
            WindowCenter.Instance.windowAfterOpenEvent -= OnWindowOpen;
            WindowCenter.Instance.windowBeforeCloseEvent -= OnWindowPreClose;
        }
 
        private void OnWindowOpen(Window _window)
        {
            if (parent != _window)
            {
                return;
            }
 
            container.SetActive(true);
            CheckGuide();
 
            var underwayGuides = FunctionalGuideCenter.Instance.GetUnderwayGuides();
            for (int i = 0; i < underwayGuides.Count; i++)
            {
                var guideId = underwayGuides[i];
                if (GuideBelongtoThisTrigger(guideId))
                {
                    BeginFunctionalGuide(guideId);
                }
            }
 
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionOpen;
            PlayerDatas.Instance.playerDataRefreshEvent += OnLevelChange;
            TaskModel.Event_MainlineTask += OnMainLineTaskUpdate;
            TaskModel.CardLevelChange += OnMainLineTaskLimitStateChange;
            FunctionUnlockFlyObject.functionUnLockShowEndEvent += OnFunctionUnLockShowEnd;
 
            FunctionalGuideCenter.Instance.beginGuideEvent += BeginFunctionalGuide;
            FunctionalGuideCenter.Instance.removeGuideEvent += OnGuideRemove;
 
            taskModel.taskDescriptionRefresh += OnMainLineTaskDescriptionIndexUpdate;
            treasureModel.treasureCollectProgressRefresh += OnTreasureCollectingStateChange;
            treasureModel.treasureStageUpEvent += OnTreasureStageChange;
            achievementModel.achievementAwardableEvent += OnAchievementAwardAble;
        }
 
        private void OnWindowPreClose(Window _window)
        {
            if (parent != _window)
            {
                return;
            }
 
            foreach (var behaviour in behaviours.Values)
            {
                if (behaviour != null)
                {
                    FunctionalGuideBehaviourPool.Recycle(behaviour.gameObject);
                }
            }
 
            behaviours.Clear();
            container.SetActive(false);
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionOpen;
            PlayerDatas.Instance.playerDataRefreshEvent -= OnLevelChange;
            TaskModel.Event_MainlineTask -= OnMainLineTaskUpdate;
            TaskModel.CardLevelChange -= OnMainLineTaskLimitStateChange;
            FunctionUnlockFlyObject.functionUnLockShowEndEvent -= OnFunctionUnLockShowEnd;
 
            FunctionalGuideCenter.Instance.beginGuideEvent -= BeginFunctionalGuide;
            FunctionalGuideCenter.Instance.removeGuideEvent -= OnGuideRemove;
 
            taskModel.taskDescriptionRefresh -= OnMainLineTaskDescriptionIndexUpdate;
            treasureModel.treasureCollectProgressRefresh -= OnTreasureCollectingStateChange;
            treasureModel.treasureStageUpEvent -= OnTreasureStageChange;
            achievementModel.achievementAwardableEvent -= OnAchievementAwardAble;
        }
 
        private void OnFunctionOpen(int _functionId)
        {
            CheckGuide();
        }
 
        private void OnLevelChange(PlayerDataType refreshType)
        {
            switch (refreshType)
            {
                case PlayerDataType.LV:
                    CheckGuide();
                    break;
            }
        }
 
        private void OnMainLineTaskUpdate(int _taskId, int _state)
        {
            CheckGuide();
        }
 
        private void OnMainLineTaskDescriptionIndexUpdate(int _taskId)
        {
            CheckGuide();
        }
 
        private void OnMainLineTaskLimitStateChange(int _taskId)
        {
            CheckGuide();
        }
 
        private void OnFunctionUnLockShowEnd(FunctionUnlockType _type)
        {
            CheckGuide();
        }
 
        private void OnTreasureCollectingStateChange(int _treasureId)
        {
            CheckGuide();
        }
 
        private void OnTreasureStageChange(int _treasureId)
        {
            CheckGuide();
        }
 
        private void OnAchievementAwardAble(int _achievementId)
        {
            CheckGuide();
        }
 
        private void CheckGuide()
        {
            FunctionalGuideCenter.Instance.CheckGuides(guides);
        }
 
        private void OnGuideRemove(int _guide)
        {
            if (behaviours.ContainsKey(_guide))
            {
                FunctionalGuideBehaviourPool.Recycle(behaviours[_guide].gameObject);
                behaviours.Remove(_guide);
            }
        }
 
        private void BeginFunctionalGuide(int _guide)
        {
            if (!GuideBelongtoThisTrigger(_guide))
            {
                return;
            }
 
            var behaviour = FunctionalGuideBehaviourPool.Require();
            var behaviourRectTransform = (RectTransform)behaviour.transform;
            behaviourRectTransform.MatchWhith(container);
            behaviour.SetActive(true);
            behaviour.BeginGuide(_guide);
 
            behaviours[_guide] = behaviour;
        }
 
        private bool GuideBelongtoThisTrigger(int _guide)
        {
            for (int i = 0; i < guides.Length; i++)
            {
                if (guides[i] == _guide)
                {
                    return true;
                }
            }
 
            return false;
        }
 
 
    }
 
}