RechargeStoreView.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using UI.RechargeStore;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. namespace GFGGame
  5. {
  6. public class RechargeStoreView : BaseWindow
  7. {
  8. private UI_RechargeStoreUI _ui;
  9. private ValueBarController _valueBarController;
  10. public override void Dispose()
  11. {
  12. _valueBarController.Dispose();
  13. _valueBarController = null;
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. }
  18. _ui = null;
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_RechargeStoreUI.PACKAGE_NAME;
  25. _ui = UI_RechargeStoreUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _valueBarController = new ValueBarController(_ui.m_valueBar);
  29. _ui.m_btnBack.onClick.Add(OnClickBtnBack);
  30. InitList();
  31. }
  32. protected override void OnShown()
  33. {
  34. base.OnShown();
  35. _valueBarController.OnShown();
  36. }
  37. protected override void OnHide()
  38. {
  39. base.OnHide();
  40. _valueBarController.OnHide();
  41. }
  42. private void OnClickBtnBack()
  43. {
  44. this.Hide();
  45. }
  46. private void InitList()
  47. {
  48. _ui.m_list.RemoveChildren();
  49. RechargeCfg[] dataArray = RechargeCfgArray.Instance.dataArray;
  50. int len = dataArray.Length;
  51. for (int i = 0; i < len; i++)
  52. {
  53. RechargeCfg itemData = dataArray[i];
  54. UI_StoreListItem itemUI = UI_StoreListItem.Proxy();
  55. itemUI.m_btnBuy.text = "¥" + itemData.price;
  56. itemUI.m_btnBuy.onClick.Add(() =>
  57. {
  58. RechargeSProxy.ReqRecharge(itemData.id).Coroutine();
  59. });
  60. itemUI.m_txtName.text = itemData.name + "x" + itemData.itemNum;
  61. itemUI.m_imgDouble.visible = false;
  62. itemUI.m_icon.url = "ui://RechargeStore/sc_zizhuan_" + itemData.id;
  63. _ui.m_list.AddChild(itemUI.target);
  64. // int order = i + 1;
  65. // if((order)%3 == 0 && order < len)
  66. // {
  67. // GLoader line = new GLoader();
  68. // line.autoSize = true;
  69. // line.url = "ui://RechargeStore/sc_kuangjiazi_2";
  70. // _ui.m_list.AddChild(line);
  71. // }
  72. UI_StoreListItem.ProxyEnd();
  73. }
  74. }
  75. }
  76. }