LuckyBoxNewCardView.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. using System.Collections.Generic;
  2. using cfg.GfgCfg;
  3. using ET;
  4. using FairyGUI;
  5. using UI.LuckyBox;
  6. using UnityEngine;
  7. namespace GFGGame
  8. {
  9. public class LuckyBoxNewCardView : BaseWindow
  10. {
  11. private UI_LuckyBoxNewCardUI _ui;
  12. // private List<int> _newCardList = new List<int>();
  13. // private List<ItemData> _newDressList = new List<ItemData>();
  14. private int _cardId;
  15. public override void Dispose()
  16. {
  17. if (_ui != null)
  18. {
  19. _ui.Dispose();
  20. _ui = null;
  21. }
  22. base.Dispose();
  23. }
  24. protected override void OnInit()
  25. {
  26. base.OnInit();
  27. packageName = UI_LuckyBoxNewCardUI.PACKAGE_NAME;
  28. _ui = UI_LuckyBoxNewCardUI.Create();
  29. this.viewCom = _ui.target;
  30. isfullScreen = true;
  31. _ui.m_loaBg.onClick.Add(OnClickBg);
  32. _ui.m_btnShare.onClick.Add(OnClickShare);
  33. }
  34. protected override void AddEventListener()
  35. {
  36. base.AddEventListener();
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. _ui.m_loaBg.touchable = false;
  42. _cardId = (int)this.viewData;
  43. // _newCardList = new List<int>((this.viewData as object[])[0] as List<int>);
  44. if (!GetSuitItemController.isAuto)
  45. {
  46. _ui.m_btnShare.visible = false;
  47. }
  48. else
  49. {
  50. _ui.m_btnShare.visible = false;
  51. }
  52. updateView();
  53. Timers.inst.Add(0.5f, 1, OnTimerClick);
  54. }
  55. private void updateView()
  56. {
  57. ItemCfg cfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(_cardId);
  58. _ui.m_loaBg.url = ResPathUtil.GetCardPath(cfg.Res);
  59. }
  60. protected override void OnHide()
  61. {
  62. base.OnHide();
  63. Timers.inst.Remove(OnTimerClick);
  64. _ui.m_loaBg.touchable = true;
  65. }
  66. protected override void RemoveEventListener()
  67. {
  68. base.RemoveEventListener();
  69. }
  70. private void OnTimerClick(object param)
  71. {
  72. _ui.m_loaBg.touchable = true;
  73. }
  74. private void OnClickBg()
  75. {
  76. if (!GetSuitItemController.isAuto)
  77. {
  78. this.Hide();
  79. }
  80. }
  81. private void OnClickShare()
  82. {
  83. ShareDataManager.Instance.CaptureCameraToImage();
  84. }
  85. }
  86. }