SuitItemView.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using cfg.GfgCfg;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using UnityEngine;
  5. using UI.LuckyBox;
  6. namespace GFGGame
  7. {
  8. public class SuitItemView : BaseWindow
  9. {
  10. private UI_SuitItemUI _ui;
  11. private int suitID;
  12. private int countSuitId; //当前获得的物品还有多少个相同套装的部件需要展示
  13. private int count = 0; //套装当前拥有的部件数量
  14. private int totalCount = 1;
  15. private EffectUI _effectUI1;
  16. private EffectUI _effectUI2;
  17. private EffectUI _effectUI3;
  18. public override void Dispose()
  19. {
  20. EffectUIPool.Recycle(_effectUI1);
  21. _effectUI1 = null;
  22. EffectUIPool.Recycle(_effectUI2);
  23. _effectUI2 = null;
  24. EffectUIPool.Recycle(_effectUI3);
  25. _effectUI3 = null;
  26. if (_ui != null)
  27. {
  28. _ui.Dispose();
  29. _ui = null;
  30. }
  31. base.Dispose();
  32. }
  33. protected override void OnInit()
  34. {
  35. base.OnInit();
  36. packageName = UI_SuitItemUI.PACKAGE_NAME;
  37. _ui = UI_SuitItemUI.Create();
  38. this.viewCom = _ui.target;
  39. isfullScreen = true;
  40. _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
  41. _ui.m_probar.max = 0;
  42. EffectUIPool.CreateEffectUI(_ui.m_topEffect, "ui_LuckyBox", "SJJD_CradUp",
  43. onComplete: (effect) =>
  44. {
  45. if (effect != null)
  46. {
  47. _effectUI1 = effect;
  48. }
  49. });
  50. EffectUIPool.CreateEffectUI(_ui.m_probarEffect, "ui_LuckyBox", "SJJD_CradUP_once",
  51. onComplete: (effect) =>
  52. {
  53. if (effect != null)
  54. {
  55. _effectUI2 = effect;
  56. }
  57. });
  58. EffectUIPool.CreateEffectUI(_ui.m_downEffect, "ui_LuckyBox", "SJJD_CradDown",
  59. onComplete: (effect) =>
  60. {
  61. if (effect != null)
  62. {
  63. _effectUI3 = effect;
  64. }
  65. });
  66. }
  67. protected override void OnShown()
  68. {
  69. base.OnShown();
  70. _ui.m_loaBg.touchable = false;
  71. if (this.viewData != null)
  72. {
  73. suitID = (int)(this.viewData as object[])[0];
  74. countSuitId = (int)(this.viewData as object[])[1];
  75. }
  76. UpdateView();
  77. Timers.inst.Add(0.5f, 1, OnTimerClick);
  78. }
  79. private void UpdateView()
  80. {
  81. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  82. count = count - countSuitId;
  83. if (suitID > 0)
  84. {
  85. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitID);
  86. _ui.m_txtName.text = "套装·" + suitCfg.Name;
  87. _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.Res);
  88. }
  89. _ui.m_probar.max = totalCount;
  90. _ui.m_probar.value = count - 1;
  91. _ui.m_t_open.Play();
  92. _ui.m_probar.TweenValue(count, 0.7f);
  93. }
  94. private void OnTimerClick(object param)
  95. {
  96. _ui.m_loaBg.touchable = true;
  97. }
  98. private void OnClickBg()
  99. {
  100. if (!GetSuitItemController.isAuto)
  101. {
  102. if (count == totalCount)
  103. {
  104. ViewManager.Show<GetSuitItemVIew>(suitID);
  105. }
  106. this.Hide();
  107. //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  108. }
  109. }
  110. protected override void OnHide()
  111. {
  112. _ui.m_probar.max = 0;
  113. _ui.m_probar.value = 0;
  114. Timers.inst.Remove(OnTimerClick);
  115. _ui.m_loaBg.touchable = true;
  116. }
  117. }
  118. }