61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using TMPro;
|
|
using UnityEngine.UI;
|
|
|
|
public class MailCard : CardBase
|
|
{
|
|
public Image[] images; // 0 보상 아이콘
|
|
public TextMeshProUGUI[] texts; // 0 보상, 1 메시지, 2 남은 시간
|
|
|
|
ServerMailData m_ServerMailData;
|
|
|
|
public override void Set<T>(T _base)
|
|
{
|
|
base.Set(_base);
|
|
m_ServerMailData = _base as ServerMailData;
|
|
|
|
images[0].sprite = UIAtlasMgr.Ins.Get_Sprite(m_ServerMailData.ItemID);
|
|
texts[0].text = m_ServerMailData.Amount.ToString();
|
|
Set_Msg();
|
|
var ts = m_ServerMailData.RemnantTime - ServerInfo.ServerTime;
|
|
if (ts.TotalDays < 1) texts[2].text = DSUtil.Format(145, ts.Hours, ts.Minutes);
|
|
else texts[2].text = DSUtil.Format(146, (int)ts.TotalDays);
|
|
}
|
|
|
|
void Set_Msg()
|
|
{
|
|
if (string.IsNullOrEmpty(m_ServerMailData.Msg))
|
|
{
|
|
var itemdata = table_itemlist.Ins.Get_Data(m_ServerMailData.ItemID);
|
|
if (itemdata.e_ItemType == eItem.Shop)
|
|
{
|
|
texts[1].text = itemdata.Get_Name();
|
|
return;
|
|
}
|
|
}
|
|
texts[1].text = m_ServerMailData.Msg;
|
|
}
|
|
|
|
public void OnClick_GetReward()
|
|
{
|
|
var id = m_ServerMailData.ItemID;
|
|
var amount = m_ServerMailData.Amount;
|
|
var sinfo = ServerInfo.Ins;
|
|
|
|
sinfo.Get_MailReward(m_ServerMailData.RemainTime,
|
|
error =>
|
|
{
|
|
switch (error)
|
|
{
|
|
case 3:
|
|
ToastUI.Ins.Set(144);
|
|
break;
|
|
default:
|
|
// TODO 정인호 : 상점 패키지 확인 필요
|
|
sinfo.m_ServerData.Add_Item(id, amount);
|
|
sinfo.Write(() => { ObtainItemUI.Ins.Set(new ItemSimpleData { itemid = id, amount = amount }); });
|
|
break;
|
|
}
|
|
MailUI.Ins.Del_Mail(m_ServerMailData);
|
|
});
|
|
}
|
|
} |