RandomGFGoStop/Assets/Scripts/UI/HuntingPanel.cs

141 lines
4.6 KiB
C#
Raw Normal View History

2025-08-28 20:40:15 +00:00
using BansheeGz.BGDatabase;
2025-08-27 21:08:17 +00:00
using CodeJay.Classes;
using System.Collections.Generic;
using UnityEngine;
2025-08-29 00:59:06 +00:00
public class HuntingPanel : uScrollViewMgr
2025-08-27 21:08:17 +00:00
{
[SerializeField] private TMPro.TextMeshProUGUI TitleTMP;
[SerializeField] private GameObject[] Buttons;
2025-08-28 20:40:15 +00:00
public GameObject go_mainpaenl, go_botpanel, go_x;
2025-08-27 21:08:17 +00:00
private List<HuntingSlot> _lstSlots;
2025-08-29 00:59:06 +00:00
private int CurAlbumType = 1;
2025-08-27 21:08:17 +00:00
private void Awake()
{
2025-08-29 00:59:06 +00:00
//// HuntingData하나에 2개의 데이터 필요함.
//// 100개라면 50개만 생성해야함 (왼쪽 오른쪽 있기때문)
//_lstSlots = new List<HuntingSlot>(DB_HuntingListData.CountEntities);
2025-08-27 21:08:17 +00:00
2025-08-29 00:59:06 +00:00
//// 소수점이 나오면 데이터가 홀수로 끝난다는것이기 때문에
//// 오른쪽에 슬롯이 생성되지 않는것을 방지하기위해 올림을 한다.
////int length = Mathf.CeilToInt(GameManager.DB.GetHuntingDataLength() / 2f);
2025-08-27 21:08:17 +00:00
2025-08-29 00:59:06 +00:00
//// 헌팅 도전 슬롯 생성
//HuntingSlot slot = null;
//for (int i = 0; i < DB_HuntingListData.CountEntities; i++)
//{
// slot = Instantiate(SlotPrefab, Content).GetComponent<HuntingSlot>();
// _lstSlots.Add(slot);
//}
2025-08-27 21:08:17 +00:00
if (GameManager.Instance != null)
{
// 이벤트 매니저에 구독
2025-08-29 00:59:06 +00:00
GameManager.Event.RegistEvent(EEventType.OnSynchronizeAIChllengeModeAIData, this.Set_UI);
2025-08-27 21:08:17 +00:00
GameManager.Event.RegistEvent(EEventType.OnClickFullView, this.OnClickFullView);
GameManager.Event.RegistEvent(EEventType.OnReturnFullView, this.OnReturnFullView);
}
}
private void OnDestroy()
{
if (GameManager.Instance != null)
{
// 구독한 이벤트 해제
2025-08-29 00:59:06 +00:00
GameManager.Event.RemoveEvent(EEventType.OnSynchronizeAIChllengeModeAIData, this.Set_UI);
2025-08-27 21:08:17 +00:00
GameManager.Event.RemoveEvent(EEventType.OnClickFullView, this.OnClickFullView);
GameManager.Event.RemoveEvent(EEventType.OnReturnFullView, this.OnReturnFullView);
GameManager.BGDatabase.ReleaseHuntingUnlockImage();
}
}
private void OnEnable()
{
GameManager.DB.CheckDayReset();
2025-08-28 20:40:15 +00:00
go_botpanel.SetActive(false);
go_x.SetActive(true);
2025-08-29 00:59:06 +00:00
Set_UI();
2025-08-27 21:08:17 +00:00
}
2025-08-29 00:59:06 +00:00
public void Set_UI()
2025-08-27 21:08:17 +00:00
{
2025-08-29 00:59:06 +00:00
Set_ScrollView(GameManager.DB.Get_AlbumDatas(CurAlbumType), GameManager.DB.GetUnlockTargetIndex());
2025-08-27 21:08:17 +00:00
}
private void OnClickFullView(object huntingDataID, object huntingListDataID)
{
for (int i = 0; i < Buttons.Length; i++)
Buttons[i].SetActive(false);
}
private void OnReturnFullView()
{
for (int i = 0; i < Buttons.Length; i++)
Buttons[i].SetActive(true);
}
public void ClickUnlockNowButton()
{
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
if (GameManager.DB.IsAllUnlocked() == false)
{
if (GameManager.DB.Key > 0)
{
GameManager.DB.SubKey(1, this.name);
GameManager.DB.UnlockLastAIImage();
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);
}
}
else
{
GameManager.UI.ShowNStackPopup(EPopupType.KeyChargePopup);
}
}
}
public void ClickChallenge()
{
GameManager.Sound.PlaySFX(ESFXType.Button_Hit);
if (GameManager.DB.IsAllUnlocked() == false)
{
if (GameManager.DB.Heart > 0)
{
if (GameManager.DB.Gold > 0)
{
GameManager.DB.SubHeart(1, this.name);
GameManager.Event.InvokeEvent(EEventType.OnChallengeStart);
}
else
{
GameManager.UI.ShowNStackPopup(EPopupType.GoldChargePopup);
}
}
else
GameManager.UI.ShowNStackPopup(EPopupType.HeartChargePopup);
}
}
2025-08-28 20:40:15 +00:00
public void OnClick_X()
{
2025-08-28 21:18:14 +00:00
gameObject.SetActive(false);
2025-08-28 20:40:15 +00:00
go_botpanel.SetActive(true);
go_mainpaenl.SetActive(true);
go_x.SetActive(false);
}
2025-08-27 21:08:17 +00:00
}