using vnxbqy.UI;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
class SkillMatchBehaviour
|
{
|
|
Transform parent;
|
RectTransform selectSymbol;
|
Text skillName;
|
ImageEx skillIcon;
|
UIDragDropBehaviour dragDrop;
|
|
int id;
|
|
public void Bind(Transform parent)
|
{
|
this.parent = parent;
|
this.selectSymbol = parent.FindComponentEx<RectTransform>("Img_Select");
|
this.skillName = parent.FindComponentEx<Text>("Txt_SkillName");
|
this.skillIcon = parent.FindComponentEx<ImageEx>("Img_Icon");
|
this.dragDrop = parent.GetComponentEx<UIDragDropBehaviour>();
|
}
|
|
public void Display(int id)
|
{
|
this.parent.SetActiveIL(true);
|
this.id = id;
|
|
var skillid = SkillMatchModel.Instance.GetSkillId(id);
|
var config = SkillConfig.Get(skillid);
|
|
this.skillName.text = config.SkillName;
|
this.skillIcon.SetSprite(config.IconName);
|
|
var treasureSkillModel = ModelCenter.Instance.GetModelEx<TreasureSkillModel>();
|
|
TreasureSkill skill;
|
if (treasureSkillModel.TryGetSkill(skillid, out skill))
|
{
|
this.skillIcon.gray = skill.level <= 0;
|
this.dragDrop.Init(this.id);
|
this.dragDrop.SetDragDropState(skill.level > 0);
|
DisplaySelect();
|
}
|
else
|
{
|
DebugEx.LogErrorFormat("skillid不存在:{0}", skillid);
|
}
|
this.dragDrop.onClick += OnClick;
|
}
|
|
public void DisplaySelect()
|
{
|
this.selectSymbol.SetActiveIL(this.id == SkillMatchModel.Instance.selectId);
|
}
|
|
public void Dispose()
|
{
|
this.dragDrop.onClick -= OnClick;
|
this.parent.SetActiveIL(false);
|
}
|
|
void OnClick(int id)
|
{
|
SkillMatchModel.Instance.selectId = id;
|
}
|
|
public int GetId()
|
{
|
return this.id;
|
}
|
|
}
|