RandomGFGoStop/Assets/Scripts/UI/HuntingPanel.cs

160 lines
5.3 KiB
C#

using CodeJay.Classes;
using System;
using System.Collections.Generic;
using UnityEngine;
using static BansheeGz.BGDatabase.BGJsonRepoModel;
public class HuntingPanel : uScrollViewMgr
{
[SerializeField] private TMPro.TextMeshProUGUI TitleTMP, t_type;
[SerializeField] private GameObject[] Buttons;
public GameObject go_mainpaenl, go_botpanel, go_x;
public ShowPanel m_ShowPanel;
private List<HuntingSlot> _lstSlots;
private int CurAlbumType = 1;
private void Awake()
{
//// HuntingData하나에 2개의 데이터 필요함.
//// 100개라면 50개만 생성해야함 (왼쪽 오른쪽 있기때문)
//_lstSlots = new List<HuntingSlot>(DB_HuntingListData.CountEntities);
//// 소수점이 나오면 데이터가 홀수로 끝난다는것이기 때문에
//// 오른쪽에 슬롯이 생성되지 않는것을 방지하기위해 올림을 한다.
////int length = Mathf.CeilToInt(GameManager.DB.GetHuntingDataLength() / 2f);
//// 헌팅 도전 슬롯 생성
//HuntingSlot slot = null;
//for (int i = 0; i < DB_HuntingListData.CountEntities; i++)
//{
// slot = Instantiate(SlotPrefab, Content).GetComponent<HuntingSlot>();
// _lstSlots.Add(slot);
//}
if (GameManager.Instance != null)
{
// 이벤트 매니저에 구독
GameManager.Event.RegistEvent(EEventType.OnSynchronizeAIChllengeModeAIData, this.Set_UI);
GameManager.Event.RegistEvent(EEventType.OnClickFullView, this.OnClickFullView);
GameManager.Event.RegistEvent(EEventType.OnReturnFullView, this.OnReturnFullView);
}
}
public void ShowPanel(HuntingData data)
{
m_ShowPanel.Set(data);
}
private void OnDestroy()
{
if (GameManager.Instance != null)
{
// 구독한 이벤트 해제
GameManager.Event.RemoveEvent(EEventType.OnSynchronizeAIChllengeModeAIData, this.Set_UI);
GameManager.Event.RemoveEvent(EEventType.OnClickFullView, this.OnClickFullView);
GameManager.Event.RemoveEvent(EEventType.OnReturnFullView, this.OnReturnFullView);
GameManager.BGDatabase.ReleaseHuntingUnlockImage();
}
}
private void OnEnable()
{
GameManager.DB.CheckDayReset();
go_botpanel.SetActive(false);
go_x.SetActive(true);
Set_UI();
}
public void Set_UI()
{
//GameManager.DB.GetHuntingDataLength()
var curtargetindex = GameManager.DB.GetUnlockTargetIndex(true);
DB_HuntingListData huntingListData = DB_HuntingListData.GetEntity(Mathf.FloorToInt((float)((float)curtargetindex / 2.0f)));
TitleTMP.text = huntingListData.DBF_Title;
t_type.text = $"Type{CurAlbumType}";
Set_ScrollView(GameManager.DB.Get_AlbumDatas(CurAlbumType));
}
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);
//}
}
public void OnClick_Arrow(int add)
{
CurAlbumType += add;
if (CurAlbumType < 1) CurAlbumType = 10;
else if (CurAlbumType > 10) CurAlbumType = 1;
Set_UI();
}
public void OnClick_X()
{
gameObject.SetActive(false);
go_botpanel.SetActive(true);
go_mainpaenl.SetActive(true);
go_x.SetActive(false);
}
}