240 lines
8.2 KiB
C#
240 lines
8.2 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using CodeJay.Classes;
|
|
using UnityEngine.ResourceManagement.AsyncOperations;
|
|
using BansheeGz.BGDatabase;
|
|
using UnityEngine.EventSystems;
|
|
using TMPro;
|
|
using DG.Tweening;
|
|
|
|
public class HuntingSlot : CardBase
|
|
{
|
|
public Material mat_blur;
|
|
[SerializeField] private TextMeshProUGUI NameTMP;
|
|
|
|
[Space(20)]
|
|
[SerializeField] private Image AI_Left;
|
|
[SerializeField] private Image AI_Right;
|
|
[SerializeField] private GameObject Block_Left;
|
|
[SerializeField] private GameObject Block_Right, Heart_Right;
|
|
public GameObject[] gos_openbutton; // 0 캐시, 1 하트
|
|
public TextMeshProUGUI[] texts_price;
|
|
public TextMeshProUGUI[] texts; // 0 lv, 1 point
|
|
|
|
[SerializeField] private GameObject[] Right_GOs;
|
|
|
|
[SerializeField] private ScrollRect sr;
|
|
|
|
private bool _fullview_Left = false;
|
|
private bool _fullview_Right = false;
|
|
private HuntingData _data_left;
|
|
private HuntingData _data_right;
|
|
|
|
private DB_HuntingData _huntigdata_left;
|
|
private DB_HuntingData _huntigdata_right;
|
|
|
|
private BGId _huntingListID;
|
|
|
|
public override void Set<T>(T _base, int iLoop = -1, int idata = -1)
|
|
{
|
|
base.Set(_base, iLoop, idata);
|
|
var data = _base as HuntingUIData;
|
|
|
|
_data_left = data.m_Left;
|
|
_data_right = data.m_Right;
|
|
|
|
SetData(iLoop);
|
|
}
|
|
|
|
public void SetData(int index)
|
|
{
|
|
//DB_HuntingListData huntingListData = DB_HuntingListData.GetEntity(Mathf.FloorToInt((float)((float)index / 2.0f)));
|
|
//_huntingListID = huntingListData.Id;
|
|
|
|
//_data_left = GameManager.DB.GetHuntingData(index);
|
|
//_data_right = GameManager.DB.GetHuntingData(index + 1);
|
|
|
|
var unlockTargetIndex_left = GameManager.DB.GetUnlockTargetIndex(true);
|
|
var unlockTargetIndex_right = GameManager.DB.GetUnlockTargetIndex(false);
|
|
|
|
texts_price[0].text = _data_left.NeedKey.ToString();
|
|
texts_price[1].text = _data_right.NeedHeart.ToString();
|
|
texts[0].text = $"Lv.{_data_left.NeedLv}";
|
|
texts[1].text = $"점 {_data_left.ClearConditionMoney}";
|
|
|
|
_huntigdata_left = DB_HuntingData.GetEntity(new BansheeGz.BGDatabase.BGId(_data_left.HuntingDataID));
|
|
|
|
if (GameManager.BGDatabase.LoadUnlockHuntingImageHandle[_huntigdata_left.GetDBF_UnlockImageAddressablesAddress()].Status == AsyncOperationStatus.Succeeded)
|
|
{
|
|
AI_Right.sprite = AI_Left.sprite = GameManager.BGDatabase.LoadUnlockHuntingImageHandle[_huntigdata_left.GetDBF_UnlockImageAddressablesAddress()].Result as Sprite;
|
|
}
|
|
|
|
//NameTMP.text = huntingListData.DBF_Title;
|
|
//NameTMP.text = $"{huntingListData.DBF_Title}\n<color=yellow>{_data_left.Name}</color>";
|
|
//AI_Left.sprite = GameManager.Resource.GetAISpriteFromResources(_data_left.TextureIndex);
|
|
|
|
if (_data_right == null)
|
|
{
|
|
for (int i = 0; i < Right_GOs.Length; i++)
|
|
Right_GOs[i].SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < Right_GOs.Length; i++)
|
|
Right_GOs[i].SetActive(true);
|
|
|
|
_huntigdata_right = DB_HuntingData.GetEntity(new BansheeGz.BGDatabase.BGId(_data_right.HuntingDataID));
|
|
|
|
//if (GameManager.BGDatabase.LoadUnlockHuntingImageHandle[_huntigdata_right.GetDBF_UnlockImageAddressablesAddress()].Status == AsyncOperationStatus.Succeeded)
|
|
//{
|
|
// AI_Right.sprite = GameManager.BGDatabase.LoadUnlockHuntingImageHandle[_huntigdata_right.GetDBF_UnlockImageAddressablesAddress()].Result as Sprite;
|
|
//}
|
|
//AI_Right.sprite = GameManager.Resource.GetAISpriteFromResources(_data_right.TextureIndex);
|
|
}
|
|
|
|
gos_openbutton[0].SetActive(false);
|
|
gos_openbutton[1].SetActive(false);
|
|
|
|
AI_Left.color = Color.white;
|
|
AI_Left.material = null;
|
|
if (_data_left != null)
|
|
{
|
|
if (_data_left.n_Group == unlockTargetIndex_left)
|
|
{ // 구매 가능
|
|
gos_openbutton[0].SetActive(true);
|
|
AI_Left.material = mat_blur;
|
|
Block_Left.SetActive(true);
|
|
}
|
|
else if (_data_left.n_Group > unlockTargetIndex_left)
|
|
{ // 잠김
|
|
Block_Left.SetActive(true);
|
|
AI_Left.color = Color.black;
|
|
}
|
|
else
|
|
{ // 열림
|
|
Block_Left.SetActive(false);
|
|
}
|
|
}
|
|
|
|
AI_Right.color = Color.white;
|
|
AI_Right.material = null;
|
|
if (_data_right != null)
|
|
{
|
|
if (_data_right.n_Group == unlockTargetIndex_right)
|
|
{ // 구매 가능
|
|
gos_openbutton[1].SetActive(true);
|
|
AI_Right.material = mat_blur;
|
|
Block_Right.SetActive(true);
|
|
Heart_Right.SetActive(true);
|
|
}
|
|
else if (_data_right.n_Group > unlockTargetIndex_right)
|
|
{ // 잠김
|
|
Block_Right.SetActive(true);
|
|
AI_Right.color = Color.black;
|
|
Heart_Right.SetActive(false);
|
|
}
|
|
else
|
|
{ // 열림
|
|
Block_Right.SetActive(false);
|
|
Heart_Right.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ClickAIImage(bool isLeft)
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
|
|
if (isLeft)
|
|
{
|
|
if (_fullview_Left)
|
|
GameManager.Event.InvokeEvent(EEventType.OnClickFullView, new BGId(_data_left.HuntingDataID), _huntingListID);
|
|
}
|
|
else
|
|
{
|
|
if (_data_right != null && _fullview_Right)
|
|
GameManager.Event.InvokeEvent(EEventType.OnClickFullView, new BGId(_data_right.HuntingDataID), _huntingListID);
|
|
}
|
|
}
|
|
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|
{
|
|
sr.OnBeginDrag(eventData);
|
|
}
|
|
|
|
public void OnDrag(PointerEventData eventData)
|
|
{
|
|
sr.OnDrag(eventData);
|
|
}
|
|
|
|
public void OnEndDrag(PointerEventData eventData)
|
|
{
|
|
sr.OnEndDrag(eventData);
|
|
}
|
|
|
|
public void OnClick_Buy(bool left)
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
|
|
if (GameManager.DB.IsAllUnlocked(left) == false)
|
|
{
|
|
var bCondition = false;
|
|
if (left)
|
|
{
|
|
if (GameManager.DB.Key >= _data_left.NeedKey)
|
|
{
|
|
GameManager.DB.SubKey(_data_left.NeedKey, this.name);
|
|
bCondition = true;
|
|
}
|
|
else
|
|
{
|
|
GameManager.UI.ShowNStackPopup(EPopupType.KeyChargePopup);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (GameManager.DB.Heart >= _data_right.NeedHeart)
|
|
{
|
|
GameManager.DB.SubHeart(_data_right.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);
|
|
|
|
//BGId huntingDataID = GameManager.BGDatabase.GetLastUnolockHuntingDataID();
|
|
//BGId huntingListDataID = GameManager.BGDatabase.GetLastUnolockHuntingListDataID();
|
|
//if (huntingDataID != BGId.Empty && huntingListDataID != BGId.Empty)
|
|
//{
|
|
// GameManager.Event.InvokeEvent(EEventType.OnClickFullView, huntingDataID, huntingListDataID);
|
|
//}
|
|
}
|
|
}
|
|
}
|
|
|
|
public void OnClick_Slot(bool left)
|
|
{
|
|
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
|
|
|
|
var unlockTargetIndex = GameManager.DB.GetUnlockTargetIndex(left);
|
|
var group = left ? _data_left.n_Group : _data_right.n_Group;
|
|
|
|
if (group == unlockTargetIndex)
|
|
{ // 구매 가능
|
|
}
|
|
else if (group > unlockTargetIndex)
|
|
{ // 잠김
|
|
}
|
|
else
|
|
{ // 열림
|
|
GameObject.Find("AlbumPanel").GetComponent<HuntingPanel>().ShowPanel(left ? _data_left : _data_right);
|
|
}
|
|
}
|
|
} |