少年修仙传客户端代码仓库
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
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, February 19, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
using System;
 
namespace vnxbqy.UI
{
 
    public class MainPositionTween : MonoBehaviour
    {
        [Header("切换按钮旋转")]
        public Vector3 Vec3 = new Vector3(0f, 0f, 225f);//切换旋转的角度
        [SerializeField] Transform m_ImageRotation;//切换滚动
        [SerializeField] RedpointBehaviour m_RightSwitchPoint;
 
        [Header("主界面顶部上下切换模块")]
        public float rightTopSwitchTime = 1f;
        [SerializeField] Transform m_RightTopFunction;
        [SerializeField] Transform m_ContainerBossList;
        [SerializeField] Transform m_RightTopPosition1;
        [SerializeField] Transform m_RightTopPosition2;
 
        [Header("主界面顶部左右切换模块")]
        [SerializeField] Transform m_TRightFunction;
        [SerializeField] Transform m_RightTopPosition3;
        [SerializeField] Transform m_RightTopPosition4;
 
        [Header("主界面技能面板切换模块")]
        public float rightBottomSwitchTime = 1.2f;
        [SerializeField] Transform m_ContainerSkill;//技能面板
        [SerializeField] Transform m_SkillPosition1;
        [SerializeField] Transform m_SkillPosition2;
        [SerializeField] RightBottomFadeInOut m_FunctionFadeInOut;//右下角按钮组
 
        [Header("主界面任务模块")]
        public float leftMiddleSwitchTime = 0.5f;//任务面板移动的速度
        [SerializeField] Transform m_ContainerLeftMiddle;
        [SerializeField] Transform m_LeftMiddlePosition1;
        [SerializeField] Transform m_LeftMiddlePosition2;
        [SerializeField] GameObject m_LeftImage;
        [SerializeField] GameObject m_RightImg;
 
        [SerializeField] ClickScreenOtherSpace m_RayMask;//便捷切换按钮            
 
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
 
        public void Init()
        {
            this.enabled = true;
        }
 
        public void UnInit()
        {
            this.enabled = false;
        }
 
        void Start()
        {
            m_RayMask.AddListener(MarkRayButton);
            DTC0102_tagCDBPlayer.switchAccountEvent += OnSwitchAccount;
        }
 
        void LateUpdate()
        {
            var alwayShow = NewBieCenter.Instance.IsAreaNeedUnflod(2) || FunctionalGuideCenter.Instance.IsAreaNeedUnflod(2);
            if (!alwayShow)
            {
                if (resetToDefaultTimer > 0f)
                {
                    resetToDefaultTimer -= Time.deltaTime;
                    if (resetToDefaultTimer <= 0f)
                    {
                        SwitchFunctions(new SwitchParam() { showDefault = true, immediately = false });
                    }
                }
            }
        }
 
        public void ShowTaskImmedidately(bool show, bool force)
        {
            if (!force)
            {
                if (taskUserPrefer == TaskUserPrefer.Show && !show)
                {
                    return;
                }
 
                if (taskUserPrefer == TaskUserPrefer.Hide && show)
                {
                    return;
                }
            }
 
            taskShow = show;
            m_LeftImage.SetActive(show);
            m_RightImg.SetActive(!show);
            m_ContainerLeftMiddle.DOKill();
            m_ContainerLeftMiddle.localPosition = show ? m_LeftMiddlePosition1.localPosition : m_LeftMiddlePosition2.localPosition;
        }
 
        public void ShowTask(bool show, bool force, bool byUser)
        {
            if (!force && !byUser)
            {
                if (taskUserPrefer == TaskUserPrefer.Show && !show)
                {
                    return;
                }
 
                if (taskUserPrefer == TaskUserPrefer.Hide && show)
                {
                    return;
                }
            }
 
            if (byUser)
            {
                taskUserPrefer = show ? TaskUserPrefer.Show : TaskUserPrefer.Hide;
            }
 
            taskShow = show;
            m_LeftImage.SetActive(show);
            m_RightImg.SetActive(!show);
 
            var endX = show ? m_LeftMiddlePosition1.localPosition.x : m_LeftMiddlePosition2.localPosition.x;
            m_ContainerLeftMiddle.DOLocalMoveX(endX, leftMiddleSwitchTime);
        }
 
        static TaskUserPrefer taskUserPrefer = TaskUserPrefer.None;
        public static bool taskShow { get; private set; }
        public static RightTopState rightTopState { get; private set; }
        public static RightBottomState rightBottomState { get; private set; }
        public static bool isDefaultState { get; private set; }
        public static event Action<bool> switchFunctionStateEvent;
 
        public static float resetToDefaultTimer = 0;
        public static void SetRecoverToSkillTimer()
        {
            resetToDefaultTimer = 8f;
        }
 
        public void SwitchFunctions(SwitchParam switchParams)
        {
            if (switchParams.manual && switchParams.showDefault)
            {
                resetToDefaultTimer = 0f;
            }
            ProcessSwitch(switchParams);
 
            m_RightSwitchPoint.SetActive(MainPositionTween.isDefaultState);
        }
 
        private void ProcessSwitch(SwitchParam switchParams)
        {
            var mapId = PlayerDatas.Instance.baseData.MapID;
            var isDungeon = MapUtility.IsDungeon(mapId);
            var isNeutralMap = GeneralDefine.neutralBossMaps.Contains(mapId);
            var isBossArea = PlayerDatas.Instance.hero != null && MapArea.IsInMapArea(PlayerDatas.Instance.hero.CurMapArea, MapArea.E_Type.Boss);
            var isGuiding = NewBieCenter.Instance.inGuiding;
 
            m_ContainerBossList.SetActive(isNeutralMap);
 
            rightTopState = RightTopState.Function;
            if ((isDungeon || isNeutralMap || isBossArea || AdventureStage.Instance.IsInAdventureStage)
                && !isGuiding && switchParams.showDefault)
            {
                if (resetToDefaultTimer >0)
                { rightTopState = RightTopState.Function; }
                else
                    rightTopState = RightTopState.Boss;
            }
            else
            {
                rightTopState = RightTopState.Function;
            }
 
            switch (rightTopState)
            {
                case RightTopState.Function:
                    if (switchParams.immediately)
                    {
                        m_RightTopFunction.localPosition = m_RightTopPosition1.localPosition;
                        m_ContainerBossList.localPosition = m_RightTopPosition2.localPosition;
                        m_TRightFunction.localPosition = m_RightTopPosition3.localPosition;
                    }
                    else
                    {
                        m_RightTopFunction.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
                        m_ContainerBossList.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
                        m_TRightFunction.DOLocalMoveX(m_RightTopPosition3.localPosition.x, rightTopSwitchTime);
                    }
                    break;
                case RightTopState.Boss:
                    if (switchParams.immediately)
                    {
                        m_ContainerBossList.localPosition = m_RightTopPosition1.localPosition;
                        m_RightTopFunction.localPosition = m_RightTopPosition2.localPosition;
                        m_TRightFunction.localPosition = m_RightTopPosition4.localPosition;
                    }
                    else
                    {
                        m_ContainerBossList.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
                        m_RightTopFunction.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
                        m_TRightFunction.DOLocalMoveX(m_RightTopPosition4.localPosition.x, rightTopSwitchTime);
                    }
                    break;
            }
 
            var rightBottomState = RightBottomState.Skill;
            switch (switchParams.bottomState)
            {
                case RightBottomState.None:
                    rightBottomState = resetToDefaultTimer <= 0f
                    && switchParams.showDefault
                    && !isGuiding
                    && !(treasureModel.newGotShowing && WindowCenter.Instance.IsOpen<TreasureNewGotWin>())
                    ? RightBottomState.Skill : RightBottomState.Function;
                    break;
                default:
                    rightBottomState = switchParams.bottomState;
                    break;
            }
 
            switch (rightBottomState)
            {
                case RightBottomState.Function:
                    if (switchParams.immediately)
                    {
                        m_FunctionFadeInOut.SwitchImmedidately(true);
                        m_ContainerSkill.localPosition = m_SkillPosition2.localPosition;
                    }
                    else
                    {
                        m_FunctionFadeInOut.Switch(true);
                        m_ContainerSkill.DOLocalMoveX(m_SkillPosition2.localPosition.x, rightBottomSwitchTime);
                    }
                    break;
                case RightBottomState.Skill:
                    if (switchParams.immediately)
                    {
                        m_FunctionFadeInOut.SwitchImmedidately(false);
                        m_ContainerSkill.localPosition = m_SkillPosition1.localPosition;
                    }
                    else
                    {
                        m_FunctionFadeInOut.Switch(false);
                        m_ContainerSkill.DOLocalMoveX(m_SkillPosition1.localPosition.x, rightBottomSwitchTime);
                    }
                    break;
            }
 
            isDefaultState = rightBottomState == RightBottomState.Skill;
            resetToDefaultTimer = !isDefaultState ? 8f : 0f;
            m_RayMask.SetActive(!isDefaultState);
 
            if (switchParams.immediately)
            {
                m_ImageRotation.localEulerAngles = isDefaultState ? Vector3.zero : new Vector3(0, 0, 225);
            }
            else
            {
                m_ImageRotation.DOLocalRotate(isDefaultState ? Vector3.zero : new Vector3(0, 0, 225), rightBottomSwitchTime);
            }
 
            if (switchFunctionStateEvent != null)
            {
                switchFunctionStateEvent(switchParams.immediately);
            }
        }
 
        private void MarkRayButton()
        {
            if (NewBieCenter.Instance.inGuiding)
            {
                return;
            }
 
            if (treasureModel.treasureStageUpShow || treasureModel.newGotShowing)
            {
                return;
            }
 
            resetToDefaultTimer = 0.0001f;
        }
 
        private void OnSwitchAccount()
        {
            taskUserPrefer = TaskUserPrefer.None;
        }
 
        public enum RightTopState
        {
            Function,
            Boss,
        }
 
        public enum RightBottomState
        {
            None,
            Function,
            Skill,
        }
 
        public enum TaskUserPrefer
        {
            None,
            Show,
            Hide,
        }
 
        public struct SwitchParam
        {
            public bool showDefault;
            public bool immediately;
            public bool manual;
            public RightBottomState bottomState;
        }
 
    }
 
}