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