FirstChargeBonusView.cs 2.2 KB

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