Project_WL/Assets/Script/UI/Kettle/CardInKettlePotion.cs

67 lines
1.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CardInKettlePotion : CardBase
{
public UISprite[] sprites; // 0 아이콘, 1 버튼, 2 공체
public UILabel[] labels; // 0 개수, 1 남은 시간, 2 마녀 or 펫
KettleTableData m_Tdata;
private void Awake()
{
Act_Repeat_for1sec = Set_RemainTime;
}
public override void Set<T>(T _base)
{
base.Set(_base);
m_Tdata = _base as KettleTableData;
sprites[0].spriteName = m_Tdata.Icon;
sprites[2].spriteName = m_Tdata.Stat == eStat.ATK ? "reinforce_attack" : "reinforce_hp";
labels[2].text = m_Tdata.m_Role == eRole.PC ? "마녀" : "펫";
Set_UI();
}
public override void Set_UI()
{
var sdata = ServerInfo.Ins.m_ServerData;
var amount = sdata.Get_ItemAmount(eItem.Potion, m_Tdata.ID);
labels[0].text = amount.ToString();
sprites[1].spriteName = amount > 0 ? "button5" : MyValue.OffButtonName;
Set_RemainTime();
}
void Set_RemainTime()
{
if (m_Tdata == null) return;
var sdata = ServerInfo.Ins.m_ServerData;
var sec = sdata.Get_PotionRemainTime(m_Tdata.ID);
if (sec > 3600) labels[1].text = DSUtil.Format("{0}시간", sec / 3600);
else if (sec == 0) labels[1].text = "";
else labels[1].text = DSUtil.Get_TimeText_MS(sec);
}
public void OnClick_Icon()
{
ItemDescUI.Ins.Set(m_Tdata.Icon, m_Tdata.Name, m_Tdata.Desc);
}
public void OnClick_Use()
{
Use(true);
}
public void Use(bool _showtoast)
{
var sdata = ServerInfo.Ins.m_ServerData;
if (sdata.Check_ItemAmount(eItem.Potion, 1, m_Tdata.ID, _showtoast))
{
sdata.Add_PotionTime(m_Tdata.ID);
Content_Potion.Ins.Set_UI();
NewGameUI.Ins.m_GuideQuestUI.Add_GuideQuest(ePurpose.UsePotion);
}
}
}