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.
184 lines
5.6 KiB
184 lines
5.6 KiB
using Coffee.UIEffects;
|
|
using IVDataFormat;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class EScrShopPack : EScrCell
|
|
{
|
|
private static readonly string CosBg = "cosbg";
|
|
private static readonly Vector2 V2_RewPosUp = new Vector2(0f, 126f);
|
|
private static readonly Vector2 V2_RewPosDown = new Vector2(0f, 10f);
|
|
|
|
private GameObject goMileage;
|
|
private GameObject goClose;
|
|
private GridLayoutGroup glgList;
|
|
private ButtonIV btnPrice;
|
|
private RectTransform rtrfReward;
|
|
private Image imgItem;
|
|
private Image imgCosBg;
|
|
private UIShiny shinyItem;
|
|
|
|
private TextMeshProUGUI txtName;
|
|
private TextMeshProUGUI txtLimit;
|
|
private TextMeshProUGUI txtMileage;
|
|
private TextMeshProUGUI txtClose;
|
|
private TextMeshProUGUI txtPrice;
|
|
|
|
private GoodsItem[] goodsItems;
|
|
|
|
|
|
|
|
public override void InitCell()
|
|
{
|
|
Transform trfself = transform;
|
|
|
|
rtrfReward = trfself.Find("reward").GetComponent<RectTransform>();
|
|
goMileage = trfself.Find("goMileage").gameObject;
|
|
goClose = trfself.Find("goClose").gameObject;
|
|
glgList = trfself.Find("groupList").GetComponent<GridLayoutGroup>();
|
|
btnPrice = trfself.Find("btnBuy").GetComponent<ButtonIV>();
|
|
imgItem = rtrfReward.Find("img").GetComponent<Image>();
|
|
imgCosBg = trfself.Find("bgcos").GetComponent<Image>();
|
|
shinyItem = imgItem.GetComponent<UIShiny>();
|
|
|
|
txtName = trfself.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
txtLimit = trfself.Find("txtLimit").GetComponent<TextMeshProUGUI>();
|
|
txtMileage = goMileage.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtClose = goClose.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtPrice = btnPrice.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
|
|
goodsItems = glgList.transform.GetComponentsInChildren<GoodsItem>();
|
|
}
|
|
|
|
public override void ReleaseResources()
|
|
{
|
|
//imgCosBg.sprite = null;
|
|
imgItem.sprite = null;
|
|
}
|
|
|
|
public override void RefreshCellView()
|
|
{
|
|
SetData(itemID);
|
|
}
|
|
|
|
public override void SetFloat(float fvalue)
|
|
{
|
|
shinyItem.effectFactor = fvalue;
|
|
}
|
|
|
|
public override void SetData(int itemid)
|
|
{
|
|
itemID = itemid;
|
|
|
|
int key = ShopMgr.SSGetPackKey(itemid);
|
|
if (key < 0)
|
|
return;
|
|
|
|
dShop data = DataHandler.GetShop(key);
|
|
txtName.text = LocalizationText.GetText(FormatString.CombineAllString("shop", key.ToString()));
|
|
|
|
// 상품 이미지 표시.
|
|
imgItem.sprite = ShopMgr.SGetShopImg(data.path);
|
|
imgItem.SetNativeSize();
|
|
//imgCosBg.sprite = ShopMgr.SGetShopImg(CosBg);
|
|
|
|
// 코스튬 패키지.
|
|
if (data.shopType == eShopType.CostumePack)
|
|
{
|
|
rtrfReward.anchoredPosition = V2_RewPosDown;
|
|
glgList.gameObject.SetActive(false);
|
|
imgCosBg.gameObject.SetActive(true);
|
|
shinyItem.effectFactor = 1f;
|
|
}
|
|
else
|
|
{
|
|
// 구성품 표시.
|
|
for (int k = 0; k < goodsItems.Length; k++)
|
|
{
|
|
if (k >= data.rewards.Length)
|
|
{
|
|
goodsItems[k].gameObject.SetActive(false);
|
|
continue;
|
|
}
|
|
nReward reward = data.rewards[k];
|
|
goodsItems[k].SetGoods(reward.rewardType, reward.rewardId, reward.rewardCount);
|
|
goodsItems[k].gameObject.SetActive(true);
|
|
}
|
|
int igridcol = data.rewards.Length;
|
|
if (igridcol > 4)
|
|
igridcol = (igridcol + 1) / 2;
|
|
glgList.constraintCount = igridcol;
|
|
rtrfReward.anchoredPosition = V2_RewPosUp;
|
|
glgList.gameObject.SetActive(true);
|
|
imgCosBg.gameObject.SetActive(false);
|
|
}
|
|
|
|
// 구매 제한 텍스트 표시.
|
|
if (data.refreshType == eRefreshType.None)
|
|
{
|
|
txtLimit.enabled = false;
|
|
}
|
|
else
|
|
{
|
|
txtLimit.enabled = true;
|
|
txtLimit.text = FormatString.TextShopLimit(data.refreshType, data.refreshValue, data.limitCnt - data.buyCnt, data.limitCnt);
|
|
}
|
|
|
|
// 가격 표시.
|
|
txtPrice.text = DataHandler.GetShopPrice(key, 1);
|
|
//btnPrice.interactable = true;
|
|
|
|
// 마일리지 표시.
|
|
if (data.mileage > 0)
|
|
{
|
|
txtMileage.text = FormatString.TextAddInt(data.mileage);
|
|
goMileage.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
goMileage.SetActive(false);
|
|
}
|
|
|
|
// 안 열림.
|
|
if (!DataHandler.IsClearStage(data.openStage))
|
|
{
|
|
txtClose.fontSizeMax = 26f;
|
|
txtClose.color = Global.CLR_TextYellow;
|
|
txtClose.text = FormatString.TextCondition(eCondition.StageClear, data.openStage);
|
|
goClose.SetActive(true);
|
|
}
|
|
// 구매 완료.
|
|
else if (data.refreshType != eRefreshType.None && data.buyCnt >= data.limitCnt)
|
|
{
|
|
txtClose.fontSizeMax = 32f;
|
|
txtClose.color = Global.CLR_White;
|
|
txtClose.text = LocalizationText.GetText("all_buycomp");
|
|
goClose.SetActive(true);
|
|
}
|
|
// 열림.
|
|
else
|
|
{
|
|
goClose.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnBtnInfo()
|
|
{
|
|
if (goClose.activeSelf)
|
|
return;
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
ShopMgr.SOpenPackInfo(ShopMgr.SSGetPackKey(itemID));
|
|
}
|
|
|
|
public void OnBtnBuy()
|
|
{
|
|
if (goClose.activeSelf)
|
|
return;
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
ShopMgr.STryBuy(ShopMgr.SSGetPackKey(itemID));
|
|
}
|
|
}
|