using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class HeroPosHeadCell : MonoBehaviour
|
{
|
[SerializeField] HeroHeadBaseCell heroHeadBaseCell;
|
[SerializeField] Image jobImg;
|
[SerializeField] Text nameText;
|
[SerializeField] Transform selectRect;
|
|
public void Display(int index)
|
{
|
var guid = HeroUIManager.Instance.heroOnTeamSortList[index];
|
var hero = HeroManager.Instance.GetHero(guid);
|
var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
|
selectRect.SetActive(team.GetHero(guid) != null);
|
|
heroHeadBaseCell.Init(hero.heroId, hero.SkinID, hero.heroStar, hero.awakeLevel, hero.heroLevel, () =>
|
{
|
Click(hero, index);
|
});
|
nameText.text = hero.breakLevel == 0 ? hero.heroConfig.Name : Language.Get("herocardbreaklv", hero.heroConfig.Name, hero.breakLevel);
|
|
jobImg.SetSprite(HeroUIManager.Instance.GetJobIconName(hero.heroConfig.Class));
|
}
|
|
void Click(HeroInfo hero, int index)
|
{
|
//检查是否可上阵,查找上阵位置,显示勾选,飞入上阵位置
|
var team = TeamManager.Instance.GetTeam(HeroUIManager.Instance.selectTeamType);
|
int pos;
|
if (selectRect.gameObject.activeSelf)
|
{
|
selectRect.SetActive(false);
|
if (team.RemoveHero(hero, out pos))
|
{
|
//通知刷新(下阵)
|
HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos }, -1, Vector3.zero);
|
}
|
return;
|
}
|
|
team.AddHero(hero, out pos);
|
if (pos != -1)
|
{
|
selectRect.SetActive(true);
|
//通知刷新,上阵,图片飞入(上阵位置)
|
HeroUIManager.Instance.NotifyOnTeamPosChangeEvent(new List<int>() { pos }, index, heroHeadBaseCell.transform.position);
|
}
|
}
|
}
|