FirstChargeBonusView.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using ET;
  2. using FairyGUI;
  3. using UI.BornLimit;
  4. using UI.CommonGame;
  5. namespace GFGGame
  6. {
  7. public class FirstChargeBonusView : BaseWindow
  8. {
  9. private UI_FirstChargeBonusUI _ui;
  10. public override void Dispose()
  11. {
  12. if (_ui != null)
  13. {
  14. _ui.Dispose();
  15. _ui = null;
  16. }
  17. base.Dispose();
  18. }
  19. protected override void OnInit()
  20. {
  21. base.OnInit();
  22. packageName = UI_FirstChargeBonusUI.PACKAGE_NAME;
  23. _ui = UI_FirstChargeBonusUI.Create();
  24. this.viewCom = _ui.target;
  25. this.modal = true;
  26. this.viewCom.Center();
  27. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  28. _ui.m_list.itemRenderer = ListItemRender;
  29. _ui.m_btnCharge.onClick.Add(OnBtnChargeClick);
  30. _ui.m_btnGet.onClick.Add(OnBtnGetClick);
  31. }
  32. protected override void OnShown()
  33. {
  34. base.OnShown();
  35. }
  36. protected override void OnHide()
  37. {
  38. base.OnHide();
  39. if (_ui.m_list.numItems > 0) _ui.m_list.ScrollToView(0);
  40. }
  41. private void OnBtnChargeClick()
  42. {
  43. }
  44. private async void OnBtnGetClick()
  45. {
  46. bool result = await ActivitySProxy.ReqFirstChargeBonusRewards();
  47. if (result)
  48. {
  49. UpdateView();
  50. }
  51. }
  52. private void UpdateView()
  53. {
  54. _ui.m_list.numItems = GlobalCfgArray.globalCfg.firstChargeBonusArr.Length;
  55. _ui.m_c1.selectedIndex = ActivityDataManager.Instance.firstChargeBonusStatus;
  56. }
  57. private void ListItemRender(int index, GObject obj)
  58. {
  59. UI_ComItem item = UI_ComItem.Proxy(obj);
  60. int[] reward = GlobalCfgArray.globalCfg.firstChargeBonusArr[index];
  61. ItemData itemData = ItemUtil.createItemData(reward);
  62. if (obj.data == null)
  63. {
  64. obj.data = new ItemView(obj as GComponent);
  65. }
  66. (obj.data as ItemView).SetData(itemData);
  67. UI_ComItem.ProxyEnd();
  68. }
  69. }
  70. }