Project_WL/Assets/Script/UI/Center/Mail/MailCard.cs

61 lines
1.8 KiB
C#
Raw Permalink Normal View History

using System.Collections.Generic;
2025-04-14 02:10:38 +00:00
using TMPro;
using UnityEngine.UI;
2024-12-15 01:39:39 +00:00
public class MailCard : CardBase
{
2025-04-14 02:10:38 +00:00
public Image[] images; // 0 보상 아이콘
public TextMeshProUGUI[] texts; // 0 보상, 1 메시지, 2 남은 시간
2024-12-15 01:39:39 +00:00
ServerMailData m_ServerMailData;
public override void Set<T>(T _base)
{
base.Set(_base);
m_ServerMailData = _base as ServerMailData;
2025-04-14 04:15:52 +00:00
images[0].sprite = UIAtlasMgr.Ins.Get_Sprite(m_ServerMailData.ItemID);
texts[0].text = m_ServerMailData.Amount.ToString();
2025-04-23 21:31:52 +00:00
Set_Msg();
2025-04-14 04:15:52 +00:00
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);
2024-12-15 01:39:39 +00:00
}
2025-04-23 21:31:52 +00:00
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;
}
2024-12-15 01:39:39 +00:00
public void OnClick_GetReward()
{
2025-04-14 04:15:52 +00:00
var id = m_ServerMailData.ItemID;
var amount = m_ServerMailData.Amount;
2024-12-15 01:39:39 +00:00
var sinfo = ServerInfo.Ins;
sinfo.Get_MailReward(m_ServerMailData.RemainTime,
error =>
{
switch (error)
{
case 3:
ToastUI.Ins.Set(144);
break;
default:
ObtainItemUI.Ins.Set(new ItemSimpleData { itemid = id, amount = amount });
sinfo.m_ServerData.Add_Item(id, amount);
2024-12-15 01:39:39 +00:00
break;
}
2025-04-14 02:34:12 +00:00
MailUI.Ins.Del_Mail(m_ServerMailData);
2024-12-15 01:39:39 +00:00
});
}
}