BuyCoinPanel.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine.Purchasing;
  6. public class BuyCoinPanel : PopUpPanel
  7. {
  8. public Transform coinContainer;
  9. public BuyCoinItem coinItemPrefab;
  10. public Transform cubeContainer;
  11. public BuyCoinItem cubeItemPrefab;
  12. public Text title;
  13. public Text vipInfo;
  14. public Text vipPrice;
  15. void Awake()
  16. {
  17. title.text = Language.GetStr ("BuyCoinPanel", "title");
  18. vipInfo.text = Language.GetStr ("BuyCoinPanel", "vipInfo");
  19. }
  20. // Use this for initialization
  21. void Start ()
  22. {
  23. List<ShopData> list = ShopManager.GetInstance ().GetCoinDataList ();
  24. ListHelper.FillList<ShopData> (coinContainer, list, coinItemPrefab);
  25. list = ShopManager.GetInstance ().GetCubeDataList ();
  26. ListHelper.FillList<ShopData> (cubeContainer, list, cubeItemPrefab);
  27. ShopData vipData = ShopManager.GetInstance ().GetVIPData ();
  28. vipPrice.text = vipData.price;
  29. }
  30. public void BuyVIP()
  31. {
  32. PaymentManager.GetIntance ().OnPurchaseClicked (ShopManager.GetInstance ().GetVIPData ().name);
  33. }
  34. override protected void Remove()
  35. {
  36. base.Remove ();
  37. currentPanel = null;
  38. }
  39. private static BuyCoinPanel currentPanel;
  40. public static BuyCoinPanel Show()
  41. {
  42. if (currentPanel != null) {
  43. currentPanel.gameObject.SetActive (true);
  44. PopUpManager.AddToMainCanvas (currentPanel.gameObject);
  45. }
  46. else
  47. currentPanel = PopUpManager.AddPopUp<BuyCoinPanel> (Resources.Load<GameObject> ("Prefabs/UI/Shop/BuyCoinPanel"), null, true);
  48. currentPanel.Open ();
  49. return currentPanel;
  50. }
  51. }