상점 구매시 아이템 삭제 추가
This commit is contained in:
parent
d5f71abd2e
commit
112c30d005
|
|
@ -1,5 +1,14 @@
|
|||
|
||||
public class ShopType1itemPrefab : ShopTypeitemPrefab
|
||||
{
|
||||
ShopUiType1 shopUiType1;
|
||||
public void Set2(ShopUiType1 shopUiType1)
|
||||
{
|
||||
this.shopUiType1=shopUiType1;
|
||||
}
|
||||
|
||||
protected override void TypeBuy()
|
||||
{
|
||||
shopUiType1.newSet();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,15 +41,28 @@ 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<ShopType1itemPrefab>().Set(item.Value);
|
||||
ShopType1itemPrefab prefab = obj.GetComponent<ShopType1itemPrefab>();
|
||||
if (prefab.Set(item.Value))
|
||||
{
|
||||
prefab.Set2(this);
|
||||
maxPage++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
defaultPos = ((maxPage - 1) * 1290) / 2;
|
||||
page.anchoredPosition = new Vector2(defaultPos, 0);
|
||||
animValue = 1;
|
||||
}
|
||||
|
||||
public void newSet()
|
||||
{
|
||||
maxPage--;
|
||||
defaultPos = ((maxPage - 1) * 1290) / 2;
|
||||
page.anchoredPosition = new Vector2(defaultPos, 0);
|
||||
animValue = 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue