using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.EventSystems;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class SkillExpertBehaviour : MonoBehaviour, IPointerDownHandler, IPointerUpHandler, IPointerExitHandler
|
{
|
[SerializeField] ImageEx m_Bottom;
|
[SerializeField] ImageEx m_Icon;
|
[SerializeField] Text m_SkillName;
|
[SerializeField] ImageEx m_ReikiBottom;
|
[SerializeField] Text m_Limit;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
[SerializeField] Button m_Select;
|
|
const float dragDelay = 0.2f;
|
|
|
public int skillId { get; private set; }
|
|
bool isUnlock = false;
|
|
bool onPress = false;
|
float m_Time = 0.0f;
|
|
TreasureSkillModel model { get { return ModelCenter.Instance.GetModel<TreasureSkillModel>(); } }
|
|
SkillModel skillModel { get { return ModelCenter.Instance.GetModel<SkillModel>(); } }
|
|
public void Display(int skillId, bool unlock)
|
{
|
this.skillId = skillId;
|
this.isUnlock = unlock;
|
|
var skillConfig = SkillConfig.Get(skillId);
|
|
m_Icon.SetSprite(skillConfig.IconName);
|
m_SkillName.text = skillConfig.SkillName;
|
|
var property = skillConfig.RequireProperty();
|
m_ReikiBottom.SetSprite("XT_LGDT_" + property);
|
|
var selectExpertSkill = 0;
|
model.TryGetExpertSkill(ExpertSkillSelectWin.skillId, out selectExpertSkill);
|
|
TreasurePotential expert;
|
model.TryGetPotential(skillId, out expert);
|
|
m_Limit.text = string.Format("{0}级可使用", expert.limitLevel);
|
|
m_Limit.gameObject.SetActive(PlayerDatas.Instance.baseData.LV < expert.limitLevel);
|
m_Bottom.gray = !unlock;
|
m_Icon.gray = !unlock;
|
m_ReikiBottom.gray = !unlock;
|
|
m_Redpoint.redpointId = expert.activeRedpoint.id;
|
|
m_Select.SetListener(OnSelect);
|
}
|
|
private void OnSelect()
|
{
|
ExpertSkillSelectWin.skillId = skillId;
|
WindowCenter.Instance.Open<ExpertSkillSelectWin>();
|
}
|
|
public void OnPointerDown(PointerEventData eventData)
|
{
|
if (!isUnlock)
|
{
|
return;
|
}
|
onPress = true;
|
}
|
|
public void OnPointerUp(PointerEventData eventData)
|
{
|
var position = Input.mousePosition;
|
if (!skillModel.skillDraging
|
&& RectTransformUtility.RectangleContainsScreenPoint(transform as RectTransform, position))
|
{
|
m_Select.OnPointerClick(eventData);
|
}
|
onPress = false;
|
m_Time = 0;
|
}
|
|
public void OnPointerExit(PointerEventData eventData)
|
{
|
}
|
|
private void LateUpdate()
|
{
|
if (onPress && !skillModel.skillDraging)
|
{
|
m_Time += Time.deltaTime;
|
if (m_Time > dragDelay)
|
{
|
skillModel.skillDragId = skillId;
|
skillModel.skillDraging = true;
|
m_Time = 0;
|
onPress = false;
|
}
|
}
|
}
|
}
|
}
|