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 MatGridBehaviour
|
{
|
|
public Transform transform;
|
ItemCell itemCell;
|
Text countText;
|
int itemID;
|
|
public void BindController(Transform target)
|
{
|
this.transform = target;
|
this.itemCell = this.transform.FindComponentEx<ItemCell>("ItemCell");
|
this.countText = this.transform.FindComponentEx<Text>("Text_Count");
|
this.itemCell.button.SetListener(() =>
|
{
|
ItemTipUtility.Show(this.itemID);
|
});
|
}
|
|
public void Init()
|
{
|
this.transform.SetActiveIL(false);
|
}
|
|
public void Init(Int2 upCostItem, int remainCount)
|
{
|
if (upCostItem == null)
|
{
|
this.transform.SetActiveIL(false);
|
return;
|
}
|
this.transform.SetActiveIL(true);
|
this.itemID = upCostItem.x;
|
this.itemCell.Init(new ItemCellModel(upCostItem.x));
|
var remainCountStr = "";
|
TextColType colorType;
|
if (remainCount < upCostItem.y)
|
{
|
colorType = TextColType.Red;
|
remainCountStr = UIHelper.AppendColor(colorType, remainCount.ToString());
|
}
|
else
|
{
|
colorType = TextColType.Green;
|
remainCountStr = UIHelper.AppendColor(colorType, remainCount.ToString(), true);
|
}
|
this.countText.text = StringUtility.Contact(remainCountStr, "/", upCostItem.y);
|
}
|
|
}
|