diff --git a/Client/Assets/1_Script/Prefab/ShopType1itemPrefab.cs b/Client/Assets/1_Script/Prefab/ShopType1itemPrefab.cs index 85354d36..8b419652 100644 --- a/Client/Assets/1_Script/Prefab/ShopType1itemPrefab.cs +++ b/Client/Assets/1_Script/Prefab/ShopType1itemPrefab.cs @@ -1,5 +1,14 @@ public class ShopType1itemPrefab : ShopTypeitemPrefab { + ShopUiType1 shopUiType1; + public void Set2(ShopUiType1 shopUiType1) + { + this.shopUiType1=shopUiType1; + } + protected override void TypeBuy() + { + shopUiType1.newSet(); + } } diff --git a/Client/Assets/1_Script/Prefab/ShopTypeitemPrefab.cs b/Client/Assets/1_Script/Prefab/ShopTypeitemPrefab.cs index b5837e08..77b1b90f 100644 --- a/Client/Assets/1_Script/Prefab/ShopTypeitemPrefab.cs +++ b/Client/Assets/1_Script/Prefab/ShopTypeitemPrefab.cs @@ -1,6 +1,3 @@ -using System; -using System.Collections; -using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -12,19 +9,23 @@ public class ShopTypeitemPrefab : MonoBehaviour ShopItemData shopItemData; - public void Set(ShopItemData shopItemData) + public bool Set(ShopItemData shopItemData) { + bool is_active; this.shopItemData = shopItemData; pay.text = "£Ü" + shopItemData.buy.ToString(); OnSet(shopItemData); Debug.Log($"{shopItemData.name} : {shopItemData.buy_count} : {shopItemData.buy_count != 0}"); - gameObject.SetActive(shopItemData.buy_count != 0); + is_active = (shopItemData.buy_count != 0); + gameObject.SetActive(is_active); + return is_active; } virtual protected void OnSet(ShopItemData shopItemData) {} - + virtual protected void TypeBuy() { } public void BuyItemButton() { + bool is_active; BuyShopItemResp resp = new BuyShopItemResp(); resp.Request((data) => { @@ -42,7 +43,12 @@ public class ShopTypeitemPrefab : MonoBehaviour GetItemWindows.Instance.SetUI(addGold, addCash, data.deck_unit, data.equipment, data.consumableItem, data.etcItem); shopItemData.buy_count--; - gameObject.SetActive(shopItemData.buy_count != 0); + is_active = (shopItemData.buy_count != 0); + if (!is_active) + { + gameObject.SetActive(is_active); + TypeBuy(); + } }, shopItemData.index, shopItemData.id); } } diff --git a/Client/Assets/1_Script/ShopUiType/ShopUiType1.cs b/Client/Assets/1_Script/ShopUiType/ShopUiType1.cs index 24d9cc44..560ccc23 100644 --- a/Client/Assets/1_Script/ShopUiType/ShopUiType1.cs +++ b/Client/Assets/1_Script/ShopUiType/ShopUiType1.cs @@ -41,13 +41,18 @@ public class ShopUiType1 : MonoBehaviour public void Set(long shop_index) { - foreach(var item in Statics.shopItems) + foreach (var item in Statics.shopItems) { - if(item.Value.shop_index == shop_index) + if (item.Value.shop_index == shop_index) { GameObject obj = Instantiate(itemPrefab, itemContent); - obj.GetComponent().Set(item.Value); - maxPage++; + ShopType1itemPrefab prefab = obj.GetComponent(); + if (prefab.Set(item.Value)) + { + prefab.Set2(this); + maxPage++; + } + } } defaultPos = ((maxPage - 1) * 1290) / 2; @@ -55,6 +60,14 @@ public class ShopUiType1 : MonoBehaviour animValue = 1; } + public void newSet() + { + maxPage--; + defaultPos = ((maxPage - 1) * 1290) / 2; + page.anchoredPosition = new Vector2(defaultPos, 0); + animValue = 1; + } + public void LeftButton() { if (index == 0)