123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- using UnityEngine;
- using UnityEngine.UI;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine.Purchasing;
- public class BuyCoinPanel : PopUpPanel
- {
- public GameObject itemPrefab;
- public Text title;
- public RectTransform container;
- public Text vipInfo;
- public Text vipPrice;
- void Awake()
- {
- title.text = Language.GetStr ("BuyCoinPanel", "title");
- vipInfo.text = Language.GetStr ("BuyCoinPanel", "vipInfo");
- }
- // Use this for initialization
- void Start ()
- {
- List<ShopData> list = ShopManager.GetInstance ().GetCoinDataList ();
- for(int i=0; i<list.Count; i++)
- {
- GameObject itemObj = Instantiate<GameObject>(itemPrefab);
- PopUpManager.AddToMainCanvas(itemObj, container);
- BuyCoinItem item = itemObj.GetComponent<BuyCoinItem>();
- item.SetData (list[i]);
- }
- ShopData vipData = ShopManager.GetInstance ().GetVIPData ();
- vipPrice.text = vipData.price;
- }
- public void BuyVIP()
- {
- PaymentManager.GetIntance ().OnPurchaseClicked (ShopManager.GetInstance ().GetVIPData ().code);
- }
- public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e)
- {
- Product product = e.purchasedProduct;
- return PurchaseProcessingResult.Complete;
- }
- /// <summary>
- /// Called when a purchase fails.
- /// </summary>
- public void OnPurchaseFailed (Product i, PurchaseFailureReason p)
- {
-
- }
- override protected void Remove()
- {
- this.gameObject.SetActive (false);
- PopUpManager.UpdateModal();
- }
- private static BuyCoinPanel currentPanel;
- public static BuyCoinPanel Show()
- {
- if (currentPanel != null) {
- currentPanel.gameObject.SetActive (true);
- PopUpManager.AddToMainCanvas (currentPanel.gameObject);
- }
- else
- currentPanel = PopUpManager.AddPopUp<BuyCoinPanel> (Resources.Load<GameObject> ("Prefabs/UI/Shop/BuyCoinPanel"), null, true);
- currentPanel.Open ();
- return currentPanel;
- }
- }
|