12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- using UnityEngine;
- using System.Collections;
- using ICTS.Localization;
- using TMPro;
- public class WaveUpsellLabel : MonoBehaviour
- {
- TextMeshProUGUI label;
- void Awake()
- {
- label = GetComponent<TextMeshProUGUI>();
- }
- #region Unity Callbacks
- void OnEnable()
- {
- UpdateLabel();
- CoreNotificationCenter.AddListener(OnPurchase, CoreNotificationType.PurchaseSuccessful);
- }
- void OnDisable()
- {
- CoreNotificationCenter.RemoveListener(OnPurchase, CoreNotificationType.PurchaseSuccessful);
- }
- #endregion
- void OnPurchase(CoreNotification note)
- {
- UpdateLabel();
- }
- void UpdateLabel()
- {
- IAPProduct product = StoreManager.Instance.GetProduct(StoreProductId.specialwave_5);
- string price;
- if (product == null)
- {
- price = Localization.instance.Get("priceNotAvailable");
- } else
- {
- price = product.currencyCode+" "+product.price;
- }
- label.text = string.Format(Localization.instance.Get("waveUpsell.text"), GetCountInInventory().ToString(), price);
- label.text = label.text.ToUpper();
- }
- int GetCountInInventory()
- {
- return InventoryManager.Instance.GetItemCount(InventoryItem.specialwave);
- }
- }
|