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.
139 lines
4.4 KiB
139 lines
4.4 KiB
using IVDataFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class EScrGear : EScrCell
|
|
{
|
|
private RectTransform rtrfSelect;
|
|
private RectTransform rtrfSet;
|
|
|
|
private GoodsItem[] goodsItems;
|
|
private RectTransform[] rtrfGoodsItems;
|
|
private GameObject[] objBadges;
|
|
private Image[] imgLocks;
|
|
private Image[] imgLvBgs;
|
|
private TextMeshProUGUI[] txtLvs;
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
rtrfSelect = trfself.Find("select").GetComponent<RectTransform>();
|
|
rtrfSet = trfself.Find("set").GetComponent<RectTransform>();
|
|
rtrfSet.GetChild(0).Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_equiping");
|
|
|
|
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;
|
|
|
|
imgLocks = trfself.Find("locks").GetComponentsInChildren<Image>(true);
|
|
imgLvBgs = trfself.Find("lvs").GetComponentsInChildren<Image>(true);
|
|
txtLvs = trfself.Find("lvs").GetComponentsInChildren<TextMeshProUGUI>(true);
|
|
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 Localize()
|
|
{
|
|
rtrfSet.GetChild(0).Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_equiping");
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
int iselectindex = -1;
|
|
int isetindex = -1;
|
|
dGear gearequip = DataHandler.GetGearEquip(iType, DataHandler.GetEquipedGear(iType));
|
|
int ilasthavekey = DataHandler.GetGearLastHaveId(iType);
|
|
int iequipkey;
|
|
int iequipunit;
|
|
if (gearequip == null)
|
|
{
|
|
iequipkey = 0;
|
|
iequipunit = 0;
|
|
}
|
|
else
|
|
{
|
|
iequipkey = gearequip.id;
|
|
iequipunit = gearequip.rarity * 100 + gearequip.grade;
|
|
}
|
|
|
|
for (int i = 0; i < goodsItems.Length; i++)
|
|
{
|
|
int key = BagMgr.SGetGearId(iType, itemid, i);
|
|
if (key < 0)
|
|
{
|
|
goodsItems[i].gameObject.SetActive(false);
|
|
goodsItems[i].ReleaseData();
|
|
imgLvBgs[i].enabled = false;
|
|
txtLvs[i].text = null;
|
|
imgLocks[i].enabled = false;
|
|
objBadges[i].SetActive(false);
|
|
continue;
|
|
}
|
|
|
|
dGear data = DataHandler.GetGearEquip(iType, key);
|
|
int iunit = data.rarity * 100 + data.grade;
|
|
|
|
goodsItems[i].gameObject.SetActive(true);
|
|
goodsItems[i].SetGoods(iType, key, data.count);
|
|
imgLvBgs[i].color = Global.CLR_RarityFront[data.rarity];
|
|
imgLvBgs[i].enabled = true;
|
|
txtLvs[i].text = FormatString.TextLv(data.level);
|
|
imgLocks[i].enabled = !data.have;
|
|
objBadges[i].SetActive(data.have && (DataHandler.IsGearNew(iType, key) || (key == ilasthavekey && iequipunit < iunit)));
|
|
|
|
if (BagMgr.SIsSelectGear(key))
|
|
iselectindex = i;
|
|
if (key == iequipkey)
|
|
isetindex = i;
|
|
}
|
|
|
|
if (iselectindex >= 0)
|
|
{
|
|
rtrfSelect.anchoredPosition = rtrfGoodsItems[iselectindex].anchoredPosition;
|
|
rtrfSelect.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
rtrfSelect.gameObject.SetActive(false);
|
|
}
|
|
|
|
if (isetindex >= 0)
|
|
{
|
|
rtrfSet.anchoredPosition = rtrfGoodsItems[isetindex].anchoredPosition;
|
|
rtrfSet.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
rtrfSet.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnBtnSelect(int ichildindex)
|
|
{
|
|
if (BagMgr.GetEfcAddAuto())
|
|
{
|
|
return;
|
|
}
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
BagMgr.SSelectGear(iType, itemID, ichildindex);
|
|
}
|
|
}
|