using BansheeGz.BGDatabase; using CodeJay.Classes; using System.Collections.Generic; using UnityEngine; public class HuntingPanel : uScrollViewMgr { [SerializeField] private TMPro.TextMeshProUGUI TitleTMP; [SerializeField] private GameObject[] Buttons; public GameObject go_mainpaenl, go_botpanel, go_x; private List _lstSlots; private int CurAlbumType = 1; private void Awake() { //// HuntingData하나에 2개의 데이터 필요함. //// 100개라면 50개만 생성해야함 (왼쪽 오른쪽 있기때문) //_lstSlots = new List(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(); // _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); } } 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() { Set_ScrollView(GameManager.DB.Get_AlbumDatas(CurAlbumType), GameManager.DB.GetUnlockTargetIndex()); } 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_X() { gameObject.SetActive(false); go_botpanel.SetActive(true); go_mainpaenl.SetActive(true); go_x.SetActive(false); } }