chunk 1: core gameplay scripts scenes runtime assets
This commit is contained in:
44
Assets/Scripts/Shop/UIProduct.cs
Normal file
44
Assets/Scripts/Shop/UIProduct.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIProduct : MonoBehaviour
|
||||
{
|
||||
[Header("Coin Package Buttons")]
|
||||
[SerializeField] private Button purchaseButton1000Coins; // Button for purchasing 1000 coins
|
||||
[SerializeField] private Button purchaseButton2150Coins; // Button for purchasing 2150 coins
|
||||
[SerializeField] private Button purchaseButton4350Coins; // Button for purchasing 4350 coins
|
||||
[SerializeField] private Button purchaseButton6700Coins; // Button for purchasing 6700 coins
|
||||
[SerializeField] private Button purchaseButton11500Coins; // Button for purchasing 11500 coins
|
||||
|
||||
private IAPManager iapManager;
|
||||
private StoreUIManager storeUIManager;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Find the IAPManager and StoreUIManager components in the scene
|
||||
iapManager = FindObjectOfType<IAPManager>();
|
||||
storeUIManager = FindObjectOfType<StoreUIManager>();
|
||||
|
||||
if (iapManager != null && storeUIManager != null)
|
||||
{
|
||||
// Assign button listeners to show the store UI and pass product details
|
||||
purchaseButton1000Coins.onClick.AddListener(() => ShowStoreUI(IAPManager.PRODUCT_1000_COINS, 1000));
|
||||
purchaseButton2150Coins.onClick.AddListener(() => ShowStoreUI(IAPManager.PRODUCT_2150_COINS, 2150));
|
||||
purchaseButton4350Coins.onClick.AddListener(() => ShowStoreUI(IAPManager.PRODUCT_4350_COINS, 4350));
|
||||
purchaseButton6700Coins.onClick.AddListener(() => ShowStoreUI(IAPManager.PRODUCT_6700_COINS, 6700));
|
||||
purchaseButton11500Coins.onClick.AddListener(() => ShowStoreUI(IAPManager.PRODUCT_11500_COINS, 11500));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("IAPManager or StoreUIManager not found in the scene.");
|
||||
}
|
||||
}
|
||||
|
||||
// Method to show the store UI with the correct product details
|
||||
private void ShowStoreUI(string productID, int coinsToAdd)
|
||||
{
|
||||
// Pass product ID and the number of coins to the StoreUIManager to display
|
||||
storeUIManager.ShowStore(productID, coinsToAdd);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user