74 lines
2.4 KiB
C#
74 lines
2.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ShopCard : CardBase
|
|
{
|
|
public TextMeshProUGUI[] texts; // 0 상품 이름, 1 제한횟수, 2 가격, 3 최초구매
|
|
public Image[] images; // 0 상품, 1 가격
|
|
public GameObject[] gos; // 0 최초 구매, 1 품절
|
|
|
|
ShopItemListTableData m_Data;
|
|
|
|
public override void Set<T>(T _base)
|
|
{
|
|
base.Set(_base);
|
|
m_Data = _base as ShopItemListTableData;
|
|
|
|
texts[0].text = m_Data.Get_Name();
|
|
texts[1].text = Get_LimitText();
|
|
texts[2].text = Get_PriceText();
|
|
|
|
texts[3].text = DSUtil.Format(390, m_Data.n_FirstBonus);
|
|
|
|
images[0].sprite = m_Data.Get_Icon();
|
|
images[1].enabled = m_Data.n_PriceItemID > 0;
|
|
if (images[1].enabled) images[1].sprite = UIAtlasMgr.Ins.Get_Sprite(m_Data.n_PriceItemID);
|
|
|
|
gos[0].SetActive(m_Data.n_FirstBonus > 0);
|
|
gos[1].SetActive(isSoldOut()); // 품절 여부
|
|
}
|
|
|
|
string Get_PriceText()
|
|
{
|
|
switch (m_Data.n_PriceItemID)
|
|
{
|
|
case -2: // 현금
|
|
return $"₩{m_Data.n_Price:N0}";
|
|
case -1: // 광고
|
|
return table_localtext.Ins.Get_Text(395);
|
|
default:
|
|
return m_Data.n_Price.ToString();
|
|
}
|
|
}
|
|
|
|
string Get_LimitText()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var buycount = sdata.Get_ShopBuyCount(m_Data.n_ShopItemID);
|
|
if (m_Data.BuyLimit > 0) return DSUtil.Format(391, buycount, m_Data.BuyLimit);
|
|
if (m_Data.BuyLimit_Day > 0) return DSUtil.Format(392, buycount, m_Data.BuyLimit_Day);
|
|
if (m_Data.BuyLimit_Week > 0) return DSUtil.Format(393, buycount, m_Data.BuyLimit_Week);
|
|
if (m_Data.BuyLimit_Month > 0) return DSUtil.Format(394, buycount, m_Data.BuyLimit_Month);
|
|
return "";
|
|
}
|
|
|
|
bool isSoldOut()
|
|
{
|
|
var sdata = ServerInfo.Ins.m_ServerData;
|
|
var buycount = sdata.Get_ShopBuyCount(m_Data.n_ShopItemID);
|
|
if (m_Data.BuyLimit > 0) return buycount >= m_Data.BuyLimit;
|
|
if (m_Data.BuyLimit_Day > 0) return buycount >= m_Data.BuyLimit_Day;
|
|
if (m_Data.BuyLimit_Week > 0) return buycount >= m_Data.BuyLimit_Week;
|
|
if (m_Data.BuyLimit_Month > 0) return buycount >= m_Data.BuyLimit_Month;
|
|
return false;
|
|
}
|
|
|
|
public void OnClick_Buy()
|
|
{
|
|
if (!isSoldOut())
|
|
{
|
|
|
|
}
|
|
}
|
|
} |