You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.3 KiB
81 lines
2.3 KiB
using IVDataFormat;
|
|
using UnityEngine;
|
|
|
|
|
|
public class EScrConsume : EScrCell
|
|
{
|
|
private RectTransform rtrfSelect;
|
|
private GoodsItem[] goodsItems;
|
|
private RectTransform[] rtrfGoodsItems;
|
|
private GameObject[] objBadges;
|
|
|
|
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
rtrfSelect = trfself.Find("select").GetComponent<RectTransform>();
|
|
|
|
Transform trfbadges = trfself.Find("badges");
|
|
objBadges = new GameObject[4];
|
|
objBadges[0] = trfbadges.Find("badge0").gameObject;
|
|
objBadges[1] = trfbadges.Find("badge1").gameObject;
|
|
objBadges[2] = trfbadges.Find("badge2").gameObject;
|
|
objBadges[3] = trfbadges.Find("badge3").gameObject;
|
|
|
|
goodsItems = trfself.GetComponentsInChildren<GoodsItem>(true);
|
|
rtrfGoodsItems = new RectTransform[goodsItems.Length];
|
|
for (int i = 0; i < rtrfGoodsItems.Length; i++)
|
|
rtrfGoodsItems[i] = goodsItems[i].GetComponent<RectTransform>();
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
int iselectindex = -1;
|
|
for (int i = 0; i < goodsItems.Length; i++)
|
|
{
|
|
int key = BagMgr.SGetConsumeId(itemid, i);
|
|
if (key < 0)
|
|
{
|
|
goodsItems[i].gameObject.SetActive(false);
|
|
goodsItems[i].ReleaseData();
|
|
objBadges[i].SetActive(false);
|
|
continue;
|
|
}
|
|
|
|
dBox data = DataHandler.SysBoxes[key];
|
|
int icount = DataHandler.GetBoxCount(key);
|
|
|
|
goodsItems[i].gameObject.SetActive(true);
|
|
goodsItems[i].SetGoods(cGoods.TBox, key, icount);
|
|
objBadges[i].SetActive(DataHandler.IsBoxNew(key));
|
|
|
|
if (BagMgr.SIsSelectConsume(key))
|
|
iselectindex = i;
|
|
}
|
|
|
|
if (iselectindex >= 0)
|
|
{
|
|
rtrfSelect.anchoredPosition = rtrfGoodsItems[iselectindex].anchoredPosition;
|
|
rtrfSelect.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
rtrfSelect.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnBtnSelect(int ichildindex)
|
|
{
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
BagMgr.SSelectConsume(itemID, ichildindex);
|
|
}
|
|
}
|