using UnityEngine;
|
using UnityEngine.UI;
|
using System.Collections.Generic;
|
|
namespace Snxxz.UI
|
{
|
public class RecycleDrugCell : MonoBehaviour
|
{
|
[SerializeField] ItemCell itemCell;
|
[SerializeField] GameObject selectImg;
|
BlastFurnaceModel blastFurnace { get { return ModelCenter.Instance.GetModel<BlastFurnaceModel>(); } }
|
|
public void SetDisplayModel(List<ItemModel> list)
|
{
|
if(list == null || list.Count < 1)
|
{
|
itemCell.gameObject.SetActive(false);
|
selectImg.SetActive(false);
|
}
|
else
|
{
|
itemCell.gameObject.SetActive(true);
|
ItemModel itemModel = list[0];
|
string key = itemModel.itemId.ToString();
|
if (blastFurnace.recycleStrlist.Contains(key))
|
{
|
selectImg.SetActive(true);
|
}
|
else
|
{
|
selectImg.SetActive(false);
|
}
|
int itemCount = 0;
|
for(int i = 0; i < list.Count; i++)
|
{
|
itemCount += list[i].count;
|
}
|
ItemCellModel cellModel = new ItemCellModel(itemModel.itemId,false,(ulong)itemCount);
|
itemCell.Init(cellModel);
|
itemCell.button.RemoveAllListeners();
|
itemCell.button.AddListener(() =>
|
{
|
if (selectImg.activeInHierarchy)
|
{
|
selectImg.SetActive(false);
|
blastFurnace.RemoveSelectRecycleDan(itemModel);
|
}
|
else
|
{
|
selectImg.SetActive(true);
|
blastFurnace.AddSelectRecycleDan(itemModel);
|
}
|
});
|
}
|
}
|
}
|
}
|