少年修仙传客户端代码仓库
client_Wu Xijin
2019-04-28 17c684a98dd8811fd22ced8da1590e08d3bc4831
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
//--------------------------------------------------------
//    [Author]:           第二世界
//    [  Date ]:           Tuesday, February 19, 2019
//--------------------------------------------------------
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using DG.Tweening;
using System;
 
namespace Snxxz.UI
{
 
    public class MainPositionTween : MonoBehaviour
    {
        [Header("切换按钮旋转")]
        public Vector3 Vec3 = new Vector3(0f, 0f, 225f);//切换旋转的角度
        [SerializeField] Transform m_ImageRotation;//切换滚动
 
        [Header("主界面顶部上下切换模块")]
        public float rightTopSwitchTime = 1f;
        [SerializeField] Transform m_RightTopFunction;
        [SerializeField] Transform m_ContainerBossList;
        [SerializeField] Transform m_RightTopPosition1;
        [SerializeField] Transform m_RightTopPosition2;
 
        [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 bool IsTaskAndPanelShow {
            get {
                return (m_ContainerLeftMiddle.localPosition - m_LeftMiddlePosition1.localPosition).sqrMagnitude < 3 * 3;
            }
        }
 
        void Start()
        {
            m_RayMask.AddListener(MarkRayButton);
        }
 
        void LateUpdate()
        {
            if (resetToDefaultTimer > 0f)
            {
                resetToDefaultTimer -= Time.deltaTime;
                if (resetToDefaultTimer <= 0f)
                {
                    SwitchFunctions(new SwitchParam() { showDefault = true, immediately = false });
                }
            }
        }
 
        public void ShowTaskImmedidately(bool show)
        {
            m_LeftImage.SetActive(show);
            m_RightImg.SetActive(!show);
            m_ContainerLeftMiddle.localPosition = show ? m_LeftMiddlePosition1.localPosition : m_LeftMiddlePosition2.localPosition;
        }
 
        public void ShowTask(bool 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);
        }
 
        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;
 
        float resetToDefaultTimer = 0;
        public void SwitchFunctions(SwitchParam switchParams)
        {
            ProcessSwitch(switchParams);
        }
 
        private void ProcessSwitch(SwitchParam switchParams)
        {
            var mapId = PlayerDatas.Instance.baseData.MapID;
            var isDungeon = MapUtility.IsDungeon(mapId);
            var isNeutralMap = false;
            var isBossArea = PlayerDatas.Instance.hero != null && MapArea.IsInMapArea(PlayerDatas.Instance.hero.CurMapArea, MapArea.E_Type.Boss);
            var isGuiding = NewBieCenter.Instance.inGuiding;
 
            if (GeneralDefine.neutralBossMaps.Contains(mapId))
            {
                isNeutralMap = true;
            }
 
            m_ContainerBossList.gameObject.SetActive(isNeutralMap);
 
            rightTopState = RightTopState.Function;
            if ((isDungeon || isNeutralMap || isBossArea || AdventureStage.Instance.IsInAdventureStage)
                && !isGuiding && switchParams.showDefault)
            {
                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;
                    }
                    else
                    {
                        m_RightTopFunction.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
                        m_ContainerBossList.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
                    }
                    break;
                case RightTopState.Boss:
                    if (switchParams.immediately)
                    {
                        m_ContainerBossList.localPosition = m_RightTopPosition1.localPosition;
                        m_RightTopFunction.localPosition = m_RightTopPosition2.localPosition;
                    }
                    else
                    {
                        m_ContainerBossList.DOLocalMoveY(m_RightTopPosition1.localPosition.y, rightTopSwitchTime);
                        m_RightTopFunction.DOLocalMoveY(m_RightTopPosition2.localPosition.y, rightTopSwitchTime);
                    }
                    break;
            }
 
            var rightBottomState = switchParams.showDefault && !isGuiding ? RightBottomState.Skill : RightBottomState.Function;
            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 ? 7f : 0f;
            m_RayMask.gameObject.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;
            }
 
            SwitchFunctions(new SwitchParam()
            {
                immediately = false,
                showDefault = true,
            });
        }
 
        public enum RightTopState
        {
            Function,
            Boss,
        }
 
        public enum RightBottomState
        {
            Function,
            Skill,
        }
 
        public struct SwitchParam
        {
            public bool showDefault;
            public bool immediately;
        }
 
    }
 
}