LuckyBoxNewCardView.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. using System.Collections.Generic;
  2. using ET;
  3. using FairyGUI;
  4. using UI.LuckyBox;
  5. using UnityEngine;
  6. namespace GFGGame
  7. {
  8. public class LuckyBoxNewCardView : BaseWindow
  9. {
  10. private UI_LuckyBoxNewCardUI _ui;
  11. private List<int> _newCardList;
  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_LuckyBoxNewCardUI.PACKAGE_NAME;
  25. _ui = UI_LuckyBoxNewCardUI.Create();
  26. this.viewCom = _ui.target;
  27. isfullScreen = true;
  28. _ui.m_loaBg.onClick.Add(OnClickBtnBg);
  29. }
  30. protected override void AddEventListener()
  31. {
  32. base.AddEventListener();
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. _newCardList = this.viewData as List<int>;
  38. }
  39. private void updateView()
  40. {
  41. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(_newCardList[0]);
  42. _ui.m_loaBg.url = ResPathUtil.GetCardPath(cfg.res);
  43. _newCardList.RemoveAt(0);
  44. }
  45. protected override void OnHide()
  46. {
  47. base.OnHide();
  48. }
  49. protected override void RemoveEventListener()
  50. {
  51. base.RemoveEventListener();
  52. }
  53. private void OnClickBtnBg()
  54. {
  55. if (_newCardList.Count > 0)
  56. {
  57. updateView();
  58. }
  59. else
  60. {
  61. this.Hide();
  62. }
  63. }
  64. }
  65. }