using System;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class ChooseCell : CommonItemBaisc
|
{
|
[SerializeField] GameObject chooseImage;
|
[SerializeField] Text nameText;
|
public int ItemId = 0;
|
private void Awake()
|
{
|
ChooseItemWin.RefreshChooseCellAct += RefreshChooseImage;
|
|
}
|
|
public void InitModel(ItemCellModel model,int id)
|
{
|
base.Init(model);
|
this.ItemId = id;
|
nameText.text = itemConfig.ItemName;
|
SetIsChoose(false);
|
|
}
|
|
private void RefreshChooseImage(int id)
|
{
|
if (id == ItemId)
|
{
|
SetIsChoose(true);
|
}
|
else
|
{
|
SetIsChoose(false);
|
}
|
}
|
|
private void SetIsChoose(bool isChoose)
|
{
|
if(isChoose)
|
{
|
chooseImage.SetActive(true);
|
}
|
else
|
{
|
chooseImage.SetActive(false);
|
}
|
}
|
|
private void OnDestroy()
|
{
|
ChooseItemWin.RefreshChooseCellAct -= RefreshChooseImage;
|
|
}
|
}
|
}
|