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;
|
}
|
|
}
|
}
|
|