From a5779d6fea0820e00f082adcf1c432f2bd630558 Mon Sep 17 00:00:00 2001 From: Ino Date: Sun, 31 Aug 2025 16:14:15 +0900 Subject: [PATCH] =?UTF-8?q?=EC=83=81=EC=A0=90=20=EC=9E=91=EC=97=85=20?= =?UTF-8?q?=EC=A4=91...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Easy Save 3/Types/ES3UserType_SaveData.cs | 8 ++- Assets/Scenes/Main.unity | 8 +++ .../Managers/AccountManager.cs | 3 +- .../SingletonManagers/Managers/DBManager.cs | 36 ++++++++++++-- Assets/Scripts/UI/ProductSlot.cs | 49 +++++++++++++++++++ Assets/Scripts/UI/StorePanel.cs | 27 +++++----- 6 files changed, 112 insertions(+), 19 deletions(-) diff --git a/Assets/Easy Save 3/Types/ES3UserType_SaveData.cs b/Assets/Easy Save 3/Types/ES3UserType_SaveData.cs index 35a5f10..cdcf248 100644 --- a/Assets/Easy Save 3/Types/ES3UserType_SaveData.cs +++ b/Assets/Easy Save 3/Types/ES3UserType_SaveData.cs @@ -26,7 +26,8 @@ namespace ES3Types writer.WriteProperty("GameSpeed", instance.GameSpeed, ES3Type_float.Instance); writer.WriteProperty("ProductAdWatchedNumber", instance.ProductAdWatchedNumber, ES3Type_int.Instance); writer.WriteProperty("FreeHeartCount", instance.FreeHeartCount, ES3Type_int.Instance); - writer.WriteProperty("InterstitialADCount", instance.InterstitialADCount, ES3Type_int.Instance); + writer.WriteProperty("FreeKeyCount", instance.FreeKeyCount, ES3Type_int.Instance); + writer.WriteProperty("InterstitialADCount", instance.InterstitialADCount, ES3Type_int.Instance); writer.WriteProperty("ImageOpenStates_Left", instance.ImageOpenStates_Left, ES3Type_boolArray.Instance); writer.WriteProperty("ImageOpenStates_Right", instance.ImageOpenStates_Right, ES3Type_boolArray.Instance); writer.WriteProperty("UnlockProgress", instance.UnlockProgress, ES3Type_longArray.Instance); @@ -73,7 +74,10 @@ namespace ES3Types case "FreeHeartCount": instance.FreeHeartCount = reader.Read(ES3Type_int.Instance); break; - case "InterstitialADCount": + case "FreeKeyCount": + instance.FreeKeyCount = reader.Read(ES3Type_int.Instance); + break; + case "InterstitialADCount": instance.InterstitialADCount = reader.Read(ES3Type_int.Instance); break; case "ImageOpenStates_Left": diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index 2d6fb39..2e2e59b 100644 --- a/Assets/Scenes/Main.unity +++ b/Assets/Scenes/Main.unity @@ -57650,6 +57650,14 @@ MonoBehaviour: - {fileID: 21300000, guid: 5943d49aa8260fd42a04c79f281dc835, type: 3} - {fileID: 21300000, guid: bc2c17814857bcc4a82dfc5e8fa0f68a, type: 3} - {fileID: 21300000, guid: ba7c63d392b1fa6449ea4e65bf25bcab, type: 3} + - {fileID: 21300000, guid: 3b1d08b7f515e5d46a05a7ff32ed1295, type: 3} + - {fileID: 21300000, guid: 0fc3518d5197ef14690a45dffc304c89, type: 3} + - {fileID: 21300000, guid: d3f914466e69bed47a1a54ce86a59b37, type: 3} + - {fileID: 21300000, guid: 7e24360e4a2cee240a33e711b9340c73, type: 3} + - {fileID: 21300000, guid: 749965a82d7a8cf468f77c2e31d94551, type: 3} + - {fileID: 21300000, guid: f36045787352db44494d1b5e4362f551, type: 3} + - {fileID: 21300000, guid: 0ec030ab67537f549941e69c78e57ea0, type: 3} + - {fileID: 21300000, guid: e857d8fc6d6313141973d87d1b17fd7d, type: 3} --- !u!114 &833499343 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/SingletonManagers/Managers/AccountManager.cs b/Assets/Scripts/SingletonManagers/Managers/AccountManager.cs index 25d00ce..c8a0b5b 100644 --- a/Assets/Scripts/SingletonManagers/Managers/AccountManager.cs +++ b/Assets/Scripts/SingletonManagers/Managers/AccountManager.cs @@ -26,7 +26,7 @@ public class AccountManager : MonoBehaviour public long Key; public long BuyKeyCount; public bool IsRemoveADS; - public int FreeHeartCount; + public int FreeHeartCount, FreeKeyCount; public long BuyShopAccumulatedMoney; } @@ -575,6 +575,7 @@ public class AccountManager : MonoBehaviour uploadData.BuyKeyCount = GameManager.DB.BuyKeyCount; uploadData.Level = GameManager.DB.NormalGameLevel; uploadData.FreeHeartCount = GameManager.DB.FreeHeartCount; + uploadData.FreeKeyCount = GameManager.DB.FreeKeyCount; uploadData.IsRemoveADS = GameManager.DB.IsRemoveADS; uploadData.BuyShopAccumulatedMoney = GameManager.DB.BuyShopAccumulatedMoney; diff --git a/Assets/Scripts/SingletonManagers/Managers/DBManager.cs b/Assets/Scripts/SingletonManagers/Managers/DBManager.cs index 1853c3d..cbed2f5 100644 --- a/Assets/Scripts/SingletonManagers/Managers/DBManager.cs +++ b/Assets/Scripts/SingletonManagers/Managers/DBManager.cs @@ -31,7 +31,7 @@ namespace CodeJay /// Number of Watched Ad In Store(Ad Heart Product). public int ProductAdWatchedNumber; - public int FreeHeartCount; + public int FreeHeartCount, FreeKeyCount; public int InterstitialADCount; public bool[] ImageOpenStates_Left, ImageOpenStates_Right; @@ -55,6 +55,7 @@ namespace CodeJay this.GameSpeed = 0.5f; this.ProductAdWatchedNumber = Constants.ADS_REWARD_COUNT; this.FreeHeartCount = Constants.FREE_HEART_DAY; + FreeKeyCount = Constants.FREE_HEART_DAY; this.InterstitialADCount = Constants.INTERSTITIAL_AD_CYCLE; this.NormalGameLevel = 1; this.NormalGame_GetGold = 0; @@ -89,6 +90,7 @@ namespace CodeJay this.GameSpeed = data.GameSpeed; this.ProductAdWatchedNumber = data.ProductAdWatchedNumber; this.FreeHeartCount = data.FreeHeartCount; + FreeKeyCount = data.FreeKeyCount; this.InterstitialADCount = data.InterstitialADCount; this.NormalGameLevel = data.NormalGameLevel; this.NormalGame_GetGold = data.NormalGame_GetGold; @@ -227,12 +229,13 @@ public partial class DBManager : MonoBehaviour public float GameSpeed { get => saveData.GameSpeed; set => saveData.GameSpeed = value; } public int ProductAdWatchedNumber { get => saveData.ProductAdWatchedNumber; } public int FreeHeartCount { get => saveData.FreeHeartCount; } + public int FreeKeyCount { get => saveData.FreeKeyCount; } public int NormalGameLevel { get => saveData.NormalGameLevel; } public int InterstitialADCount { get => saveData.InterstitialADCount; } public bool IsRemoveADS { get => saveData.IsRemoveADS; } public long BuyShopAccumulatedMoney { get => saveData.BuyShopAccumulatedMoney; } - public UnityAction OnResetFreeHeartCountEvent; + public UnityAction OnResetFreeHeartCountEvent, OnResetFreeKeyCountEvent; public UnityAction OnResetADSRewardActionCountEvent; #endregion @@ -244,7 +247,7 @@ public partial class DBManager : MonoBehaviour this.LoadDatas(); } - +#if UNITY_EDITOR private void Update() { if (Input.GetKeyDown(KeyCode.U)) @@ -279,7 +282,12 @@ public partial class DBManager : MonoBehaviour str += "\n��� : " + saveData.Gold.ToString(); Debug.Log(str); } + else if (Input.GetKeyDown(KeyCode.T)) + { + saveData.FreeKeyCount = 1; + } } +#endif private void OnDestroy() { @@ -779,6 +787,28 @@ public partial class DBManager : MonoBehaviour return 0; } + public void ResetFreeKeyCount() + { + if (saveData != null) + { + saveData.FreeKeyCount = Constants.FREE_HEART_DAY; + OnResetFreeKeyCountEvent?.Invoke(); + } + } + + public int MinFreeKeyCount(int min) + { + if (saveData != null) + { + saveData.FreeKeyCount -= min; + SaveDatas(); + + return saveData.FreeKeyCount; + } + + return 0; + } + public int MinInterstitialADCount(int min) { if (saveData != null) diff --git a/Assets/Scripts/UI/ProductSlot.cs b/Assets/Scripts/UI/ProductSlot.cs index 757444f..6f9ebd8 100644 --- a/Assets/Scripts/UI/ProductSlot.cs +++ b/Assets/Scripts/UI/ProductSlot.cs @@ -164,6 +164,35 @@ public class ProductSlot : CardBase PurchaseButton.GetComponent().color = c; } } + else if (data.productID == "key_free") + { + GameManager.DB.OnResetFreeKeyCountEvent += OnResetFreeHeartCountEvent; + + SaleGO.SetActive(false); + AdButton.SetActive(false); + PriceTMP.transform.parent.gameObject.SetActive(true); + + PriceTMP.text = "무료"; + + if (GameManager.DB.FreeKeyCount <= 0) + { + if (PurchaseButton != null) + { + Color c = PurchaseButton.GetComponent().color; + c.a = 0.5f; + PurchaseButton.GetComponent().color = c; + } + } + else + { + if (PurchaseButton != null) + { + Color c = PurchaseButton.GetComponent().color; + c.a = 1.0f; + PurchaseButton.GetComponent().color = c; + } + } + } else if (data.productID == "heart_60") { SaleGO.SetActive(true); @@ -260,6 +289,26 @@ public class ProductSlot : CardBase GameManager.UI.ShowNStackPopup(EPopupType.NotVaildFreeHeartPopup); } } + else if (_data.productID == "key_free") + { + if (GameManager.DB.FreeKeyCount > 0) + { + GameManager.DB.AddKey(1, this.name); + GameManager.DB.MinFreeKeyCount(1); + + if (GameManager.DB.FreeKeyCount <= 0 && PurchaseButton != null) + { + Color c = PurchaseButton.GetComponent().color; + c.a = 0.5f; + PurchaseButton.GetComponent().color = c; + } + } + else + { + // 무료 하트 횟수가 없다는 팝업 or 가만히 두기 + //GameManager.UI.ShowNStackPopup(EPopupType.NotVaildFreeHeartPopup); + } + } else if (_data.productID == "heart_ads") { // 광고 출력 diff --git a/Assets/Scripts/UI/StorePanel.cs b/Assets/Scripts/UI/StorePanel.cs index 5737ded..686b42d 100644 --- a/Assets/Scripts/UI/StorePanel.cs +++ b/Assets/Scripts/UI/StorePanel.cs @@ -27,7 +27,7 @@ public class StorePanel : MonoBehaviour [SerializeField] private RectTransform content; [SerializeField] private List _lstSlots; /// - /// 0 하트, 1 키, 2 냥, 3 광고 제거 + /// 0 하트, 1 키, 2 냥, 3 광고 제거, 4 무료 캐시, 5 캐시200, 6 캐시1500, 7 캐시3000, 8 무료 하트, 9 하트20, 10 하트45, 11 하트75 /// [SerializeField] private List sprites; private int BuyOneKey = 6; @@ -48,17 +48,17 @@ public class StorePanel : MonoBehaviour if (list_item.Count == 0) { list_item.Add(new ProductData("ads_remove", EProductType.IAP, "강제 광고 제거", "강제 노출 광고 제거", 5500, sprites[3], EProductReward.Delete_Ad, 1)); - list_item.Add(new ProductData("heart_free", EProductType.Gold, "일일 하트 I", "무료 하트", 0, sprites[0], EProductReward.Heart, 1)); - list_item.Add(new ProductData("heart_ads", EProductType.ADS, "일일 하트 II", "광고 후 무료 하트", 0, sprites[0], EProductReward.Heart, 1)); - list_item.Add(new ProductData("key_free", EProductType.Gold, "일일 캐시 I", "무료 캐시", 0, sprites[1], EProductReward.Key, 1)); + list_item.Add(new ProductData("heart_free", EProductType.Gold, "일일 하트 I", "무료 하트", 0, sprites[8], EProductReward.Heart, 1)); + list_item.Add(new ProductData("heart_ads", EProductType.ADS, "일일 하트 II", "광고 후 무료 하트", 0, sprites[8], EProductReward.Heart, 1)); + list_item.Add(new ProductData("key_free", EProductType.Gold, "일일 캐시 I", "무료 캐시", 0, sprites[4], EProductReward.Key, 1)); list_item.Add(new ProductData("key_cash", EProductType.Gold, "하트 1개", "보석으로 하트 획득", 200, sprites[0], EProductReward.Key, 1)); - list_item.Add(new ProductData("heart_free", EProductType.Gold, "일일 하트 I", "무료 하트", 0, sprites[0], EProductReward.Heart, 1)); - list_item.Add(new ProductData("heart_ads", EProductType.ADS, "일일 하트 II", "광고 후 무료 하트", 0, sprites[0], EProductReward.Heart, 1)); - list_item.Add(new ProductData("key_free", EProductType.Gold, "일일 캐시 I", "무료 캐시", 0, sprites[1], EProductReward.Key, 1)); - list_item.Add(new ProductData("key_cash", EProductType.Gold, "하트 1개", "보석으로 하트 획득", 200, sprites[0], EProductReward.Key, 1)); - list_item.Add(new ProductData("key_free", EProductType.Gold, "일일 캐시 I", "무료 캐시", 0, sprites[1], EProductReward.Key, 1)); - list_item.Add(new ProductData("key_cash", EProductType.Gold, "하트 1개", "보석으로 하트 획득", 200, sprites[0], EProductReward.Key, 1)); + list_item.Add(new ProductData("cash_200", EProductType.IAP, "캐시 200", "", 1000, sprites[5], EProductReward.Key, 200)); + list_item.Add(new ProductData("cash_1500", EProductType.IAP, "캐시 1500", "", 6450, sprites[6], EProductReward.Key, 1500)); + list_item.Add(new ProductData("cash_3300", EProductType.IAP, "캐시 3300", "", 11000, sprites[7], EProductReward.Key, 3300)); + list_item.Add(new ProductData("heart_20", EProductType.IAP, "하트 20개", "", 11000, sprites[9], EProductReward.Heart, 20)); + list_item.Add(new ProductData("heart_45", EProductType.IAP, "하트 45개", "", 22000, sprites[10], EProductReward.Heart, 45)); + list_item.Add(new ProductData("heart_75", EProductType.IAP, "하트 75개", "", 33000, sprites[11], EProductReward.Heart, 75)); } return; @@ -120,17 +120,18 @@ public class StorePanel : MonoBehaviour { if (this.gameObject.activeInHierarchy == false) this.gameObject.SetActive(true); - content.anchoredPosition = Vector2.zero; + 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 = Vector2.up * ((300 * 6) + (20 * 5)); + content.anchoredPosition = new Vector2(content.anchoredPosition.x, 944f); } private void OnSynchronizeKey() { - _lstSlots[BuyOneKey].SetData(new CodeJay.Classes.ProductData("10", EProductType.Gold, "열쇠 1 개", "", 100000 + (250000 * (int)GameManager.DB.BuyKeyCount), sprites[1], EProductReward.Key, 1)); + //_lstSlots[BuyOneKey].SetData(new CodeJay.Classes.ProductData("10", EProductType.Gold, "열쇠 1 개", "", 100000 + (250000 * (int)GameManager.DB.BuyKeyCount), sprites[1], EProductReward.Key, 1)); } }