少年修仙传客户端代码仓库
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
 
 
namespace vnxbqy.UI
{
    public class SkillTurnplate : SkillButtonInterface
    {
        [SerializeField] GameObject m_UpImg;
        [SerializeField] GameObject m_DownImg;
        [SerializeField] Button m_SkillSwitch;
 
        [Header("主界面第二批技能切换模块")]
        [SerializeField] Transform m_SkillGroup2;
        [SerializeField] Transform m_SG2Position1;
        [SerializeField] Transform m_SG2Position2;
        //Vector2 startPoint = Vector2.zero;
        //Vector2 endPoint = Vector2.zero;
 
        //float startTime = 0f;
        //float endTime = 0f;
 
        //float m_TargetRotationZ = 0f;
        //float refRotationZ = 0f;
 
        int groupIndex = 1;
        public int GroupIndex { get { return groupIndex; } }
        //bool turnplating = false;
 
        TreasureModel treasureModel { get { return ModelCenter.Instance.GetModel<TreasureModel>(); } }
 
        private void Awake()
        {
            DTC0102_tagCDBPlayer.switchAccountEvent += OnSwitchAccount;
        }
 
        private void OnDestroy()
        {
            DTC0102_tagCDBPlayer.switchAccountEvent -= OnSwitchAccount;
        }
 
        public void Init()
        {
 
            m_SkillSwitch.AddListener(ShowSkillGroup);
            SwitchGroup(groupIndex);
 
 
        }
        public void UnInit()
        {
 
            m_SkillSwitch.RemoveAllListeners();
        }
 
        public void ShowSkillGroup2Immedidately(bool show)
        {
            m_SkillGroup2.localPosition = show ? m_SG2Position1.localPosition : m_SG2Position2.localPosition;
        }
 
        public void ShowSkillGroup()
        {
            SwitchGroup(groupIndex == 1 ? 2 : 1);
        }
 
 
        public override void OnPointerDown(PointerEventData eventData)
        {
            base.OnPointerDown(eventData);
 
            //startTime = Time.time;
            //startPoint = eventData.position;
        }
 
        public override void OnPointerUp(PointerEventData eventData)
        {
            base.OnPointerUp(eventData);
 
            //endTime = Time.time;
            //endPoint = eventData.position;
 
            //if (IsValidGesture() && !turnplating && m_Drag)
            //{
            //    if (IsSecondPanelAllow())
            //    {
            //        var gesture = MathUtility.GetGestureDirection(startPoint, endPoint);
            //        Turn(gesture);
            //    }
            //    else
            //    {
            //        var config = TreasureConfig.Get(GeneralDefine.skillPanelUnLock);
            //        SysNotifyMgr.Instance.ShowTip("SkillPanel_Unlock", config.Name);
            //    }
            //}
        }
 
        public void SwitchGroup(int _groupIndex)
        {
            if (_groupIndex != 1 && _groupIndex != 2)
            {
                return;
            }
            m_SkillSwitch.SetActive(IsSecondPanelAllow());
            StopAllCoroutines();
            groupIndex = _groupIndex;
            ShentongModel.Instance.SetSkillPositionState(groupIndex);
 
            m_UpImg.SetActive(groupIndex == 1);
            m_DownImg.SetActive(groupIndex == 2);
 
            //m_SkillGroup2.SetActive(IsSecondPanelAllow()&&groupIndex == 2);
            ShowSkillGroup2Immedidately(IsSecondPanelAllow() && groupIndex == 2);
 
        }
 
        public bool Turn(GestureType _type = GestureType.Down)
        {
            return true;
            //if (turnplating)
            //{
            //    return false;
            //}
 
            //if (groupIndex == 1)
            //{
            //    groupIndex = 2;
            //}
            //else
            //{
            //    groupIndex = 1;
            //}
 
            //if (m_SkillGroupSign != null)
            //{
            //    m_SkillGroupSign.SetSprite(groupIndex == 1 ? "Skill_Page_1" : "Skill_Page_2");
            //}
 
            //switch (_type)
            //{
            //    case GestureType.Down:
            //    case GestureType.Left:
            //        m_TargetRotationZ = m_SkillContainer.localEulerAngles.z + 180f;
            //        StartCoroutine(Co_Turnplate(m_SkillContainer.localEulerAngles.z, m_TargetRotationZ));
            //        break;
            //    case GestureType.Up:
            //    case GestureType.Right:
            //        m_TargetRotationZ = m_SkillContainer.localEulerAngles.z - 180f;
            //        StartCoroutine(Co_Turnplate(m_SkillContainer.localEulerAngles.z, m_TargetRotationZ));
            //        break;
            //}
            //return true;
        }
 
        bool IsSecondPanelAllow()
        {
            Treasure treasure;
            return treasureModel.TryGetTreasure(GeneralDefine.skillPanelUnLock, out treasure) && treasure.state == TreasureState.Collected;
        }
 
        //bool IsValidGesture()
        //{
        //    if ((endTime - startTime) < m_TimeLimit && Vector2.Distance(startPoint, endPoint) > m_Sensitiveness)
        //    {
        //        return true;
        //    }
 
        //    return false;
        //}
 
        //IEnumerator Co_Turnplate(float _startZ, float _endZ)
        //{
        //    turnplating = true;
 
        //    float timer = 0f;
        //    float duration = 0.5f;
        //    while (timer < duration)
        //    {
        //        timer += Time.deltaTime;
        //        m_SkillContainer.localEulerAngles = new Vector3(0, 0, Mathf.Lerp(_startZ, _endZ, Mathf.Clamp01(timer / duration)));
        //        yield return null;
        //    }
 
        //    m_SkillContainer.localEulerAngles = new Vector3(0, 0, _endZ);
 
        //    turnplating = false;
        //}
 
        private void OnSwitchAccount()
        {
            groupIndex = 1;
        }
 
    }
}