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.
231 lines
8.5 KiB
231 lines
8.5 KiB
using Coffee.UIEffects;
|
|
using IVDataFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class EScrShop : EScrCell
|
|
{
|
|
private static readonly Vector2 V2_ItemSize = new Vector2(108f, 108f);
|
|
//private static readonly Vector2 V2_PriceSizeInt = new Vector2(-70f, -8f);
|
|
//private static readonly Vector2 V2_PriceSizeText = new Vector2(-96f, -8f);
|
|
|
|
private GameObject[] goItems;
|
|
private GameObject[] goMileages;
|
|
private GameObject[] goCloses;
|
|
private ButtonIV[] btnPrices;
|
|
private RectTransform[] rtrfRewards;
|
|
private RectTransform[] rtrfItems;
|
|
private RectTransform[] rtrfPrices;
|
|
private Image[] imgPriceBgs;
|
|
private Image[] imgPrices;
|
|
private Image[] imgItems;
|
|
private UIShiny[] shinyItems;
|
|
|
|
private TextMeshProUGUI[] txtNames;
|
|
private TextMeshProUGUI[] txtLimits;
|
|
private TextMeshProUGUI[] txtMileages;
|
|
private TextMeshProUGUI[] txtCloses;
|
|
private TextMeshProUGUI[] txtCounts;
|
|
private TextMeshProUGUI[] txtPrices;
|
|
|
|
[SerializeField]
|
|
Sprite[] sprBtn;
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
int ilen = trfself.childCount;
|
|
|
|
goItems = new GameObject[ilen];
|
|
goMileages = new GameObject[ilen];
|
|
goCloses = new GameObject[ilen];
|
|
btnPrices = new ButtonIV[ilen];
|
|
rtrfRewards = new RectTransform[ilen];
|
|
rtrfItems = new RectTransform[ilen];
|
|
rtrfPrices = new RectTransform[ilen];
|
|
imgPriceBgs = new Image[ilen];
|
|
imgPrices = new Image[ilen];
|
|
imgItems = new Image[ilen];
|
|
shinyItems = new UIShiny[ilen];
|
|
|
|
txtNames = new TextMeshProUGUI[ilen];
|
|
txtLimits = new TextMeshProUGUI[ilen];
|
|
txtMileages = new TextMeshProUGUI[ilen];
|
|
txtCloses = new TextMeshProUGUI[ilen];
|
|
txtCounts = new TextMeshProUGUI[ilen];
|
|
txtPrices = new TextMeshProUGUI[ilen];
|
|
|
|
for (int i = 0; i < ilen; i++)
|
|
{
|
|
Transform trfitem = trfself.GetChild(i);
|
|
|
|
goItems[i] = trfitem.gameObject;
|
|
goMileages[i] = trfitem.Find("goMileage").gameObject;
|
|
goCloses[i] = trfitem.Find("goClose").gameObject;
|
|
btnPrices[i] = trfitem.Find("btnBuy").GetComponent<ButtonIV>();
|
|
rtrfRewards[i] = trfitem.Find("reward").GetComponent<RectTransform>();
|
|
rtrfItems[i] = rtrfRewards[i].Find("img").GetComponent<RectTransform>();
|
|
rtrfPrices[i] = btnPrices[i].transform.Find("txt").GetComponent<RectTransform>();
|
|
imgPriceBgs[i] = btnPrices[i].GetComponent<Image>();
|
|
imgPrices[i] = btnPrices[i].transform.Find("icon").GetComponent<Image>();
|
|
imgItems[i] = rtrfItems[i].GetComponent<Image>();
|
|
shinyItems[i] = imgItems[i].GetComponent<UIShiny>();
|
|
|
|
txtNames[i] = trfitem.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
txtLimits[i] = trfitem.Find("txtLimit").GetComponent<TextMeshProUGUI>();
|
|
txtMileages[i] = goMileages[i].transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtCloses[i] = goCloses[i].transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtCounts[i] = rtrfRewards[i].Find("txtCount").GetComponent<TextMeshProUGUI>();
|
|
txtPrices[i] = rtrfPrices[i].GetComponent<TextMeshProUGUI>();
|
|
}
|
|
}
|
|
|
|
public override void ReleaseResources()
|
|
{
|
|
for (int i = 0; i < imgItems.Length; i++)
|
|
{
|
|
imgItems[i].sprite = null;
|
|
}
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetFloat(float fvalue)
|
|
{
|
|
for (int i = 0; i < shinyItems.Length; i++)
|
|
shinyItems[i].effectFactor = fvalue;
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
for (int i = 0; i < goCloses.Length; i++)
|
|
{
|
|
int key = ShopMgr.SSGetItemKey(itemid, i);
|
|
if (key < 0)
|
|
{
|
|
goItems[i].SetActive(false);
|
|
return;
|
|
}
|
|
|
|
goItems[i].SetActive(true);
|
|
dShop data = DataHandler.GetShop(key);
|
|
txtNames[i].text = LocalizationText.GetText(FormatString.CombineAllString("shop", key.ToString()));
|
|
|
|
// 상품 이미지, 수량 표시.
|
|
if (string.IsNullOrEmpty(data.path))
|
|
{
|
|
rtrfItems[i].sizeDelta = V2_ItemSize;
|
|
imgItems[i].sprite = AddressableMgr.GetIcon(data.rewards[0].rewardType, data.rewards[0].rewardId);
|
|
}
|
|
else
|
|
{
|
|
imgItems[i].sprite = ShopMgr.SGetShopImg(data.path);
|
|
imgItems[i].SetNativeSize();
|
|
}
|
|
txtCounts[i].text = FormatString.TextInt(data.rewards[0].rewardCount);
|
|
|
|
// 구매 제한 텍스트 표시.
|
|
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);
|
|
if (data.buyingType == cGoods.TCash)
|
|
{
|
|
imgPriceBgs[i].sprite = sprBtn[3];//현금
|
|
btnPrices[i].interactable = true;
|
|
imgPrices[i].enabled = false;
|
|
//rtrfPrices[i].sizeDelta = V2_PriceSizeText;
|
|
txtPrices[i].horizontalAlignment = HorizontalAlignmentOptions.Center;
|
|
txtPrices[i].color = Global.CLR_White;
|
|
}
|
|
else if (data.buyingType == cGoods.TAds)
|
|
{
|
|
imgPriceBgs[i].sprite = sprBtn[2];//광고
|
|
btnPrices[i].interactable = true;
|
|
imgPrices[i].sprite = AddressableMgr.GetIcon(data.buyingType, data.buyingId);
|
|
imgPrices[i].enabled = true;
|
|
//rtrfPrices[i].sizeDelta = V2_PriceSizeText;
|
|
txtPrices[i].horizontalAlignment = HorizontalAlignmentOptions.Right;
|
|
txtPrices[i].color = Global.CLR_TextYellow;
|
|
}
|
|
else
|
|
{
|
|
if (data.buyingId == cGoods.CMileage)
|
|
{
|
|
imgPriceBgs[i].sprite = sprBtn[1];//마일리지
|
|
btnPrices[i].interactable = DataHandler.Goods.mileage >= data.buyingCnt;
|
|
}
|
|
else
|
|
{
|
|
imgPriceBgs[i].sprite = sprBtn[0];//다이아
|
|
btnPrices[i].interactable = DataHandler.Goods.Dia >= data.buyingCnt;
|
|
}
|
|
imgPrices[i].sprite = AddressableMgr.GetIcon(data.buyingType, data.buyingId);
|
|
imgPrices[i].enabled = true;
|
|
//rtrfPrices[i].sizeDelta = V2_PriceSizeInt;
|
|
txtPrices[i].horizontalAlignment = HorizontalAlignmentOptions.Right;
|
|
if (btnPrices[i].interactable)
|
|
txtPrices[i].color = Global.CLR_White;
|
|
else
|
|
txtPrices[i].color = Global.CLR_TextRed;
|
|
}
|
|
|
|
// 마일리지 표시.
|
|
if (data.mileage > 0)
|
|
{
|
|
txtMileages[i].text = FormatString.TextAddInt(data.mileage);
|
|
goMileages[i].SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
goMileages[i].SetActive(false);
|
|
}
|
|
|
|
// 안 열림.
|
|
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.SSGetItemKey(itemID, irow), imgPriceBgs[irow].sprite);
|
|
}
|
|
}
|