115 lines
3.8 KiB
C#
115 lines
3.8 KiB
C#
using CodeJay.Classes;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CollectionCard : CardBase
|
|
{
|
|
public Image i_face;
|
|
public TextMeshProUGUI t_price;
|
|
public GameObject go_lock, go_buybtn, go_pricedia, go_priceheart, Heart_Right;
|
|
public Material mat_blur;
|
|
|
|
HuntingData m_Data;
|
|
|
|
public override void Set<T>(T _base, int iLoop = -1, int idata = -1)
|
|
{
|
|
base.Set(_base, iLoop, idata);
|
|
m_Data = _base as HuntingData;
|
|
|
|
var left = m_Data.Index % 2 == 0;
|
|
i_face.sprite = left ? m_Data.UnlockImage() : DB_HuntingData.GetEntity(m_Data.Index - 1).DBF_UnlockImage;
|
|
t_price.text = left ? m_Data.NeedKey.ToString() : m_Data.NeedHeart.ToString();
|
|
if (left) { go_pricedia.SetActive(true); go_priceheart.SetActive(false); }
|
|
else { go_pricedia.SetActive(false); go_priceheart.SetActive(true); }
|
|
i_face.material = null;
|
|
i_face.color = Color.white;
|
|
go_buybtn.SetActive(false);
|
|
if (left)
|
|
{
|
|
var unlockTargetIndex = GameManager.DB.GetUnlockTargetIndex(left);
|
|
if (m_Data.n_Group == unlockTargetIndex)
|
|
{ // 구매 가능
|
|
go_buybtn.SetActive(true);
|
|
i_face.material = mat_blur;
|
|
go_lock.SetActive(true);
|
|
Heart_Right.SetActive(!left);
|
|
}
|
|
else if (m_Data.n_Group > unlockTargetIndex)
|
|
{ // 잠김
|
|
go_lock.SetActive(true);
|
|
i_face.color = Color.black;
|
|
Heart_Right.SetActive(false);
|
|
}
|
|
else
|
|
{ // 열림
|
|
go_lock.SetActive(false);
|
|
Heart_Right.SetActive(!left);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (m_Data.n_Group < GameManager.DB.GetUnlockTargetIndex(true) && GameManager.DB.CanBuyHeartImage(m_Data.n_Group))
|
|
{ // 구매 가능
|
|
go_buybtn.SetActive(true);
|
|
i_face.material = mat_blur;
|
|
go_lock.SetActive(true);
|
|
Heart_Right.SetActive(true);
|
|
}
|
|
else if (!GameManager.DB.CanBuyHeartImage(m_Data.n_Group))
|
|
{ // 열림
|
|
go_lock.SetActive(false);
|
|
Heart_Right.SetActive(true);
|
|
}
|
|
else
|
|
{ // 잠김
|
|
go_lock.SetActive(true);
|
|
i_face.color = Color.black;
|
|
Heart_Right.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnClick_Buy()
|
|
{
|
|
var bCondition = false;
|
|
var left = m_Data.Index % 2 == 0;
|
|
if (left)
|
|
{
|
|
if (GameManager.DB.Key >= m_Data.NeedKey)
|
|
{
|
|
GameManager.DB.SubKey(m_Data.NeedKey, this.name);
|
|
bCondition = true;
|
|
}
|
|
else
|
|
{
|
|
GameManager.UI.ShowNStackPopup(EPopupType.KeyChargePopup);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GameManager.DB.Heart >= m_Data.NeedHeart)
|
|
{
|
|
GameManager.DB.SubHeart(m_Data.NeedHeart, this.name);
|
|
bCondition = true;
|
|
}
|
|
else
|
|
{
|
|
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
|
|
}
|
|
}
|
|
if (bCondition)
|
|
{
|
|
GameManager.DB.UnlockLastAIImage(left);
|
|
GameManager.DB.SaveDatas();
|
|
GameManager.Event.InvokeEvent(EEventType.OnSynchronizeAIChllengeModeAIData);
|
|
GameObject.Find("CollectionPanel").GetComponent<CollectionPanel>().Set_UI();
|
|
}
|
|
}
|
|
|
|
public void OnClick_CollectionCard()
|
|
{
|
|
if (!go_lock.activeInHierarchy && !go_buybtn.activeInHierarchy)
|
|
GameObject.Find("CollectionPanel").GetComponent<CollectionPanel>().ShowPanel(m_Data);
|
|
}
|
|
} |