using CodeJay.Classes; using CodeJay.Enum; using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; 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; [SerializeField] private List _lstSlots; /// /// 0 하트, 1 키, 2 냥, 3 광고 제거, 4 무료 캐시, 5 캐시200, 6 캐시1500, 7 캐시3000, 8 무료 하트, 9 하트20, 10 하트45, 11 하트75 /// [SerializeField] private List sprites; [SerializeField] private Slider slider_month; [SerializeField] private TextMeshProUGUI t_month; private int BuyOneKey = 6; public static List list_item = new List(); private void Awake() { 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) { //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[1], EProductReward.Key, 100)); 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)); list_item.Add(new ProductData("key_ads", EProductType.ADS, "일일 다이아 100개", "광고 후 무료 다이아", 0, sprites[4], EProductReward.Key, 100)); } return; _lstSlots = new List(); for (int i = 0; i < 10; i++) { if (i == BuyOneKey) { _lstSlots.Add(Instantiate(BuyKeySlotPrefab, content).GetComponent()); } else { _lstSlots.Add(Instantiate(SlotPrefab, content).GetComponent()); } } //_lstSlots[0].SetData(new CodeJay.Classes.ProductData("ads_remove", EProductType.IAP, "강제 광고 제거", "강제 노출되는 광고를 제거 합니다.", 5500, 0, EProductReward.Delete_Ad, 1)); //_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)); //_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)); //_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)); } private void OnEnable() { GameManager.DB.CheckDayReset(); for (int i = 0; i < _lstSlots.Count; i++) _lstSlots[i].Set(list_item[i]); OnSynchronizeKey(); } 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); content.anchoredPosition = new Vector2(content.anchoredPosition.x, 944f); } private void MoveToStore_Key() { // Height * 6, Spacing * 5 //content.anchoredPosition = Vector2.up * ((300 * 6) + (20 * 5)); content.anchoredPosition = new Vector2(content.anchoredPosition.x, 944f); } private void OnSynchronizeKey() { slider_month.value = GameManager.DB.TotalCashPerMonth / 700000f; t_month.text = $"{DSUtil.GetThousandCommaText(GameManager.DB.TotalCashPerMonth)}/700,000"; //_lstSlots[BuyOneKey].SetData(new CodeJay.Classes.ProductData("10", EProductType.Gold, "열쇠 1 개", "", 100000 + (250000 * (int)GameManager.DB.BuyKeyCount), sprites[1], EProductReward.Key, 1)); } }