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.
162 lines
5.7 KiB
162 lines
5.7 KiB
using IVDataFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class EScrShopCos : EScrCell
|
|
{
|
|
private GameObject[] goItems;
|
|
private GameObject[] goCloses;
|
|
private ButtonIV[] btnPrices;
|
|
private Image[] imgItems;
|
|
private Image[] imgBg;
|
|
|
|
private TextMeshProUGUI[] txtNames;
|
|
private TextMeshProUGUI[] txtLimits;
|
|
private TextMeshProUGUI[] txtCloses;
|
|
private TextMeshProUGUI[] txtPrices;
|
|
private TextMeshProUGUI[] txtEfcs;
|
|
|
|
|
|
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
int ilen = trfself.childCount;
|
|
|
|
goItems = new GameObject[ilen];
|
|
goCloses = new GameObject[ilen];
|
|
btnPrices = new ButtonIV[ilen];
|
|
imgItems = new Image[ilen];
|
|
imgBg = new Image[ilen];
|
|
|
|
txtNames = new TextMeshProUGUI[ilen];
|
|
txtLimits = new TextMeshProUGUI[ilen];
|
|
txtCloses = new TextMeshProUGUI[ilen];
|
|
txtPrices = new TextMeshProUGUI[ilen];
|
|
txtEfcs = new TextMeshProUGUI[ilen];
|
|
|
|
for (int i = 0; i < ilen; i++)
|
|
{
|
|
Transform trfitem = trfself.GetChild(i);
|
|
|
|
goItems[i] = trfitem.gameObject;
|
|
goCloses[i] = trfitem.Find("goClose").gameObject;
|
|
btnPrices[i] = trfitem.Find("btnBuy").GetComponent<ButtonIV>();
|
|
imgItems[i] = trfitem.Find("img").GetComponent<Image>();
|
|
imgBg[i] = trfitem.Find("imgBg").GetComponent<Image>();
|
|
|
|
txtNames[i] = trfitem.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
txtLimits[i] = trfitem.Find("txtLimit").GetComponent<TextMeshProUGUI>();
|
|
txtCloses[i] = goCloses[i].transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtPrices[i] = trfitem.Find("btnBuy").Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtEfcs[i] = trfitem.Find("Effect").Find("txt").GetComponent<TextMeshProUGUI>();
|
|
trfself.GetChild(i).Find("Effect").Find("txtT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("own_effect_title");
|
|
}
|
|
}
|
|
|
|
public override void Localize()
|
|
{
|
|
Transform trfself = transform;
|
|
int ilen = trfself.childCount;
|
|
for (int i = 0; i < ilen; i++)
|
|
{
|
|
trfself.GetChild(i).Find("Effect").Find("txtT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("own_effect_title");
|
|
}
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
for (int i = 0; i < goCloses.Length; i++)
|
|
{
|
|
int key = ShopMgr.SSGetCosKey(itemid, i);
|
|
if (key < 0)
|
|
{
|
|
goItems[i].SetActive(false);
|
|
return;
|
|
}
|
|
|
|
goItems[i].SetActive(true);
|
|
dShop data = DataHandler.GetShop(key);
|
|
|
|
// 상품 이름, 이미지 표시.
|
|
int irewtype = data.rewards[0].rewardType;
|
|
int irewid = data.rewards[0].rewardId;
|
|
txtNames[i].text = FormatString.GetGoodsName(irewtype, irewid);
|
|
imgItems[i].sprite = AddressableMgr.GetIcon(irewtype, irewid);
|
|
if(irewtype== cGoods.TCosCloth)
|
|
{
|
|
imgItems[i].sprite = AddressableMgr.GetIcon(cGoods.TProfileIcon, irewid);
|
|
imgBg[i].gameObject.SetActive(false);
|
|
}
|
|
else if (irewtype == cGoods.TCosWeapon)
|
|
{
|
|
//imgItems[i].sprite = AddressableMgr.GetWeaponIcon(irewid);
|
|
imgBg[i].gameObject.SetActive(true);
|
|
}
|
|
|
|
// 상품 효과 표시.
|
|
dCostume costume = data.rewards[0].rewardType == cGoods.TCosCloth ? DataHandler.GetCosCloth(irewid) : DataHandler.GetCosWeapon(irewid);
|
|
txtEfcs[i].text = FormatString.TextEffectTitleValuesBreakline(costume.abilityType1, costume.abilityValue1, costume.abilityType2, costume.abilityValue2);
|
|
|
|
// 구매 제한 텍스트 표시.
|
|
if (data.refreshType == eRefreshType.None)
|
|
{
|
|
txtLimits[i].enabled = false;
|
|
}
|
|
else
|
|
{
|
|
txtLimits[i].enabled = true;
|
|
txtLimits[i].text = FormatString.TextShopLimit(data.refreshType, data.refreshValue, data.limitCnt - data.buyCnt, data.limitCnt);
|
|
}
|
|
|
|
// 가격 표시.
|
|
txtPrices[i].text = DataHandler.GetShopPrice(key, 1);
|
|
btnPrices[i].interactable = DataHandler.Goods.Dia >= data.buyingCnt;
|
|
if (btnPrices[i].interactable)
|
|
txtPrices[i].color = Global.CLR_White;
|
|
else
|
|
txtPrices[i].color = Global.CLR_TextRed;
|
|
|
|
// 안 열림.
|
|
if (!DataHandler.IsClearStage(data.openStage))
|
|
{
|
|
txtCloses[i].fontSizeMax = 22f;
|
|
txtCloses[i].color = Global.CLR_TextYellow;
|
|
txtCloses[i].text = FormatString.TextCondition(eCondition.StageClear, data.openStage);
|
|
goCloses[i].SetActive(true);
|
|
}
|
|
// 구매 완료.
|
|
else if (data.refreshType != eRefreshType.None && data.buyCnt >= data.limitCnt)
|
|
{
|
|
txtCloses[i].fontSizeMax = 26f;
|
|
txtCloses[i].color = Global.CLR_White;
|
|
txtCloses[i].text = LocalizationText.GetText("all_buycomp");
|
|
goCloses[i].SetActive(true);
|
|
}
|
|
// 열림.
|
|
else
|
|
{
|
|
goCloses[i].SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnBtnBuy(int irow)
|
|
{
|
|
if (goCloses[irow].activeSelf)
|
|
return;
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
ShopMgr.STryBuy(ShopMgr.SSGetCosKey(itemID, irow));
|
|
}
|
|
}
|