using UnityEngine; using System.Collections; public class WaveUpsellLabel : MonoBehaviour { UILabel label; void Awake() { label = GetComponent(); } #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); } }