LuckyBoxNewCardView.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 = new List<int>();
  12. // private List<ItemData> _newDressList = new List<ItemData>();
  13. private int _cardId;
  14. public override void Dispose()
  15. {
  16. if (_ui != null)
  17. {
  18. _ui.Dispose();
  19. _ui = null;
  20. }
  21. base.Dispose();
  22. }
  23. protected override void OnInit()
  24. {
  25. base.OnInit();
  26. packageName = UI_LuckyBoxNewCardUI.PACKAGE_NAME;
  27. _ui = UI_LuckyBoxNewCardUI.Create();
  28. this.viewCom = _ui.target;
  29. isfullScreen = true;
  30. _ui.m_loaBg.onClick.Add(OnClickBg);
  31. _ui.m_btnShare.onClick.Add(OnClickShare);
  32. }
  33. protected override void AddEventListener()
  34. {
  35. base.AddEventListener();
  36. }
  37. protected override void OnShown()
  38. {
  39. base.OnShown();
  40. _ui.m_loaBg.touchable = false;
  41. _cardId = (int)this.viewData;
  42. // _newCardList = new List<int>((this.viewData as object[])[0] as List<int>);
  43. if (!GetSuitItemController.isAuto)
  44. {
  45. _ui.m_btnShare.visible = true;
  46. }
  47. else
  48. {
  49. _ui.m_btnShare.visible = false;
  50. }
  51. updateView();
  52. Timers.inst.Add(0.5f, 1, OnTimerClick);
  53. }
  54. private void updateView()
  55. {
  56. ItemCfg cfg = ItemCfgArray.Instance.GetCfg(_cardId);
  57. _ui.m_loaBg.url = ResPathUtil.GetCardPath(cfg.res);
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. Timers.inst.Remove(OnTimerClick);
  63. _ui.m_loaBg.touchable = true;
  64. }
  65. protected override void RemoveEventListener()
  66. {
  67. base.RemoveEventListener();
  68. }
  69. private void OnTimerClick(object param)
  70. {
  71. _ui.m_loaBg.touchable = true;
  72. }
  73. private void OnClickBg()
  74. {
  75. if (!GetSuitItemController.isAuto)
  76. {
  77. this.Hide();
  78. }
  79. }
  80. private void OnClickShare()
  81. {
  82. ShareDataManager.Instance.CaptureCameraToImage();
  83. }
  84. }
  85. }