61 lines
1.8 KiB
C#
61 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
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:
|
|
var lst = MailUI.Ins.Get_MailReward(new List<ItemSimpleData> { new ItemSimpleData { itemid = id, amount = amount } });
|
|
sinfo.Write(() => { ObtainItemUI.Ins.Set(lst); });
|
|
break;
|
|
}
|
|
MailUI.Ins.Del_Mail(m_ServerMailData);
|
|
});
|
|
}
|
|
} |