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.
141 lines
4.4 KiB
141 lines
4.4 KiB
using IVDataFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class EScrPet : EScrCell
|
|
{
|
|
private RectTransform rtrfSelect;
|
|
|
|
private GoodsItem[] goodsItems;
|
|
private RectTransform[] rtrfGoodsItems;
|
|
private GameObject[] goSets;
|
|
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>();
|
|
|
|
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>();
|
|
}
|
|
|
|
Image[] sets = trfself.Find("sets").GetComponentsInChildren<Image>(true);
|
|
goSets = new GameObject[sets.Length];
|
|
for (int i = 0; i < sets.Length; i++)
|
|
{
|
|
goSets[i] = sets[i].gameObject;
|
|
goSets[i].transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_equiping");
|
|
}
|
|
}
|
|
|
|
public override void Localize()
|
|
{
|
|
for (int i = 0; i < goSets.Length; i++)
|
|
{
|
|
goSets[i].transform.GetChild(0).GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_equiping");
|
|
}
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
int iselectindex = -1;
|
|
bool bpet = PetMgr.SGetSvType() == cGoods.TPet;
|
|
|
|
for (int i = 0; i < goodsItems.Length; i++)
|
|
{
|
|
int key = PetMgr.SGetPetId(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;
|
|
goSets[i].SetActive(false);
|
|
objBadges[i].SetActive(false);
|
|
continue;
|
|
}
|
|
|
|
dPet data = DataHandler.GetPet(key);
|
|
// 펫.
|
|
if (bpet)
|
|
{
|
|
goodsItems[i].SetGoods(cGoods.TPet, key, -1L);
|
|
goodsItems[i].gameObject.SetActive(true);
|
|
|
|
imgLocks[i].enabled = !data.have;
|
|
//imgLvBgs[i].color = Global.CLR_RarityFront[data.rarity];
|
|
//imgLvBgs[i].enabled = true;
|
|
txtLvs[i].text = FormatString.TextLv(data.level);
|
|
txtLvs[i].enabled = true;
|
|
goSets[i].SetActive(PetMgr.SIsSetPet(key));
|
|
objBadges[i].SetActive(DataHandler.IsPetNew(key));
|
|
}
|
|
// 스피릿.
|
|
else
|
|
{
|
|
goodsItems[i].SetGoods(cGoods.TPetSpirit, key, data.count);
|
|
goodsItems[i].gameObject.SetActive(true);
|
|
|
|
imgLocks[i].enabled = data.count <= 0;
|
|
//imgLvBgs[i].enabled = false;
|
|
txtLvs[i].enabled = false;
|
|
goSets[i].SetActive(false);
|
|
objBadges[i].SetActive(false);
|
|
}
|
|
|
|
if (PetMgr.SIsSelectPet(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)
|
|
{
|
|
if (PetMgr.GetEfcAddAuto())
|
|
{
|
|
return;
|
|
}
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
PetMgr.SSelectPet(itemID, ichildindex);
|
|
}
|
|
}
|