SuitItemView.cs 3.3 KB

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