2025-08-31 05:52:47 +00:00
using CodeJay.Classes ;
using CodeJay.Enum ;
2025-08-27 21:08:17 +00:00
using System.Collections.Generic ;
using UnityEngine ;
namespace CodeJay.Enum
{
public enum EProductReward
{
Delete_Ad ,
Heart ,
Key
}
public enum EProductType
{
ADS ,
IAP ,
Gold
}
}
public class StorePanel : MonoBehaviour
{
[SerializeField] private GameObject SlotPrefab ;
[SerializeField] private GameObject BuyKeySlotPrefab ;
[SerializeField] private RectTransform content ;
2025-08-31 05:52:47 +00:00
[SerializeField] private List < ProductSlot > _lstSlots ;
/// <summary>
2025-08-31 07:14:15 +00:00
/// 0 하트, 1 키, 2 냥, 3 광고 제거, 4 무료 캐시, 5 캐시200, 6 캐시1500, 7 캐시3000, 8 무료 하트, 9 하트20, 10 하트45, 11 하트75
2025-08-31 05:52:47 +00:00
/// </summary>
[SerializeField] private List < Sprite > sprites ;
2025-08-27 21:08:17 +00:00
private int BuyOneKey = 6 ;
2025-08-31 05:52:47 +00:00
List < ProductData > list_item = new List < ProductData > ( ) ;
2025-08-27 21:08:17 +00:00
private void Awake ( )
{
2025-08-31 05:52:47 +00:00
if ( GameManager . Instance ! = null )
{
GameManager . Event . RegistEvent ( EEventType . MoveToStore_Heart , this . MoveToStore_Heart ) ;
GameManager . Event . RegistEvent ( EEventType . MoveToStore_Heart_DuringGame , this . MoveToStore_Heart ) ;
GameManager . Event . RegistEvent ( EEventType . MoveToStore_Key , this . MoveToStore_Key ) ;
GameManager . Event . RegistEvent ( EEventType . OnReturnToGameFromStore , this . OnReturnToGameFromStore ) ;
GameManager . Event . RegistEvent ( EEventType . OnSynchronizeKey , this . OnSynchronizeKey ) ;
}
if ( list_item . Count = = 0 )
{
2025-09-05 06:41:40 +00:00
//list_item.Add(new ProductData("com.fgb.adsremove", EProductType.IAP, "강제 광고 제거", "강제 노출 광고 제거", 5500, sprites[3], EProductReward.Delete_Ad, 1));
list_item . Add ( new ProductData ( "key_free" , EProductType . Gold , "다이아 50개" , "일일 무료 다이아" , 0 , sprites [ 4 ] , EProductReward . Key , 50 ) ) ;
list_item . Add ( new ProductData ( "heart_free" , EProductType . Gold , "일일 하트 1개" , "무료 하트" , 0 , sprites [ 8 ] , EProductReward . Heart , 1 ) ) ;
list_item . Add ( new ProductData ( "heart_ads" , EProductType . ADS , "일일 하트 5개" , "광고 후 무료 하트" , 0 , sprites [ 8 ] , EProductReward . Heart , 5 ) ) ;
list_item . Add ( new ProductData ( "heart_cash" , EProductType . Gold , "하트 10개" , "다이아로 하트 구매" , 300 , sprites [ 0 ] , EProductReward . Heart , 10 ) ) ;
list_item . Add ( new ProductData ( "cash_heart" , EProductType . Gold , "다이아 100개" , "하트로 다이아 구매" , 10 , sprites [ 0 ] , EProductReward . Key , 100 ) ) ;
2025-08-31 05:52:47 +00:00
2025-09-05 07:20:45 +00:00
list_item . Add ( new ProductData ( "com.fgb.cash500" , EProductType . IAP , "다이아 500" , "보너스 없음" , 1100 , sprites [ 5 ] , EProductReward . Key , 500 ) ) ;
list_item . Add ( new ProductData ( "com.fgb.cash1800" , EProductType . IAP , "다이아 1800" , "16% 보너스" , 3300 , sprites [ 6 ] , EProductReward . Key , 1800 ) ) ;
list_item . Add ( new ProductData ( "com.fgb.cash7500" , EProductType . IAP , "다이아 7500" , "33% 보너스" , 11000 , sprites [ 7 ] , EProductReward . Key , 7500 ) ) ;
list_item . Add ( new ProductData ( "com.fgb.heart20" , EProductType . IAP , "하트 20개" , "보너스 없음" , 1100 , sprites [ 9 ] , EProductReward . Heart , 20 ) ) ;
list_item . Add ( new ProductData ( "com.fgb.heart150" , EProductType . IAP , "하트 150개" , "6.7% 보너스" , 7700 , sprites [ 10 ] , EProductReward . Heart , 150 ) ) ;
list_item . Add ( new ProductData ( "com.fgb.heart500" , EProductType . IAP , "하트 500개" , "20% 보너스" , 22000 , sprites [ 11 ] , EProductReward . Heart , 500 ) ) ;
2025-08-31 05:52:47 +00:00
}
return ;
2025-08-27 21:08:17 +00:00
_lstSlots = new List < ProductSlot > ( ) ;
for ( int i = 0 ; i < 10 ; i + + )
{
if ( i = = BuyOneKey )
{
_lstSlots . Add ( Instantiate ( BuyKeySlotPrefab , content ) . GetComponent < ProductSlot > ( ) ) ;
}
else
{
_lstSlots . Add ( Instantiate ( SlotPrefab , content ) . GetComponent < ProductSlot > ( ) ) ;
}
}
2025-08-31 05:52:47 +00:00
//_lstSlots[0].SetData(new CodeJay.Classes.ProductData("ads_remove", EProductType.IAP, "강제 광고 제거", "강제 노출되는 광고를 제거 합니다.", 5500, 0, EProductReward.Delete_Ad, 1));
2025-08-27 21:08:17 +00:00
2025-08-31 05:52:47 +00:00
//_lstSlots[1].SetData(new CodeJay.Classes.ProductData("heart_free", EProductType.Gold, "일일 무료 하트 I", "무료 하트 획득!", 0, 1, EProductReward.Heart, 1));
//_lstSlots[2].SetData(new CodeJay.Classes.ProductData("heart_ads", EProductType.ADS, "일일 무료 하트 II", "광고 시청 후 무료 하트 획득!", 0, 1, EProductReward.Heart, 1));
2025-08-27 21:08:17 +00:00
2025-08-31 05:52:47 +00:00
//_lstSlots[3].SetData(new CodeJay.Classes.ProductData("heart_10", EProductType.IAP, "하트 10개 구매", "", 1000, 1, EProductReward.Heart, 10));
//_lstSlots[4].SetData(new CodeJay.Classes.ProductData("heart_60", EProductType.IAP, "하트 60개 구매", "", 5500, 1, EProductReward.Heart, 60));
//_lstSlots[5].SetData(new CodeJay.Classes.ProductData("heart_130", EProductType.IAP, "하트 130개 구매", "", 11000, 1, EProductReward.Heart, 130));
2025-08-27 21:08:17 +00:00
2025-08-31 05:52:47 +00:00
//_lstSlots[BuyOneKey].SetData(new CodeJay.Classes.ProductData("key_1", EProductType.Gold, "열쇠 1 개", "", 100000 + (250000 * (int)GameManager.DB.BuyKeyCount), 2, EProductReward.Key, 1));
//_lstSlots[7].SetData(new CodeJay.Classes.ProductData("key_20", EProductType.IAP, "열쇠 20 개", "", 11000, 2, EProductReward.Key, 10));
//_lstSlots[8].SetData(new CodeJay.Classes.ProductData("key_45", EProductType.IAP, "열쇠 45 개", "", 22000, 2, EProductReward.Key, 25));
//_lstSlots[9].SetData(new CodeJay.Classes.ProductData("key_75", EProductType.IAP, "열쇠 75 개", "", 33000, 2, EProductReward.Key, 45));
2025-08-27 21:08:17 +00:00
}
private void OnEnable ( )
{
GameManager . DB . CheckDayReset ( ) ;
2025-08-31 05:52:47 +00:00
for ( int i = 0 ; i < _lstSlots . Count ; i + + )
_lstSlots [ i ] . Set ( list_item [ i ] ) ;
2025-08-27 21:08:17 +00:00
}
private void OnDestroy ( )
{
if ( GameManager . Instance ! = null )
{
GameManager . Event . RemoveEvent ( EEventType . MoveToStore_Heart , this . MoveToStore_Heart ) ;
GameManager . Event . RemoveEvent ( EEventType . MoveToStore_Heart_DuringGame , this . MoveToStore_Heart ) ;
GameManager . Event . RemoveEvent ( EEventType . MoveToStore_Key , this . MoveToStore_Key ) ;
GameManager . Event . RemoveEvent ( EEventType . OnReturnToGameFromStore , this . OnReturnToGameFromStore ) ;
GameManager . Event . RemoveEvent ( EEventType . OnSynchronizeKey , this . OnSynchronizeKey ) ;
}
}
private void OnReturnToGameFromStore ( )
{
this . gameObject . SetActive ( false ) ;
}
private void MoveToStore_Heart ( )
{
if ( this . gameObject . activeInHierarchy = = false )
this . gameObject . SetActive ( true ) ;
2025-08-31 07:14:15 +00:00
content . anchoredPosition = new Vector2 ( content . anchoredPosition . x , 944f ) ;
2025-08-27 21:08:17 +00:00
}
private void MoveToStore_Key ( )
{
// Height * 6, Spacing * 5
2025-08-31 07:14:15 +00:00
//content.anchoredPosition = Vector2.up * ((300 * 6) + (20 * 5));
content . anchoredPosition = new Vector2 ( content . anchoredPosition . x , 944f ) ;
2025-08-27 21:08:17 +00:00
}
private void OnSynchronizeKey ( )
{
2025-08-31 07:14:15 +00:00
//_lstSlots[BuyOneKey].SetData(new CodeJay.Classes.ProductData("10", EProductType.Gold, "열쇠 1 개", "", 100000 + (250000 * (int)GameManager.DB.BuyKeyCount), sprites[1], EProductReward.Key, 1));
2025-08-27 21:08:17 +00:00
}
}