SuitItemView.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 EffectUI _effectUI1;
  11. private int suitID;
  12. private int count = 0;//套装当前拥有的部件数量
  13. private int totalCount = 1;
  14. public override void Dispose()
  15. {
  16. EffectUIPool.Recycle(_effectUI1);
  17. _effectUI1 = null;
  18. if (_ui != null)
  19. {
  20. _ui.Dispose();
  21. _ui = null;
  22. }
  23. base.Dispose();
  24. }
  25. protected override void OnInit()
  26. {
  27. base.OnInit();
  28. packageName = UI_SuitItemUI.PACKAGE_NAME;
  29. _ui = UI_SuitItemUI.Create();
  30. this.viewCom = _ui.target;
  31. isfullScreen = true;
  32. _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
  33. }
  34. protected override void OnShown()
  35. {
  36. base.OnShown();
  37. suitID = (int)this.viewData;
  38. UpdateView();
  39. }
  40. private void UpdateView()
  41. {
  42. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  43. if (suitID > 0)
  44. {
  45. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitID);
  46. _ui.m_txtName.text = "套装·" + suitCfg.name;
  47. _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  48. }
  49. _ui.m_probar.max = totalCount;
  50. _ui.m_probar.value = count;
  51. _ui.m_t_open.Play();
  52. if (GetSuitItemController.isAuto)
  53. {
  54. Timers.inst.Add(1.2f, 1, WaitAutoEnd);
  55. }
  56. }
  57. private void OnClickBg()
  58. {
  59. if(!GetSuitItemController.isAuto)
  60. {
  61. if (count == totalCount)
  62. {
  63. ViewManager.Show<GetSuitItemVIew>(suitID);
  64. }
  65. else
  66. {
  67. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  68. }
  69. this.Hide();
  70. }
  71. }
  72. protected override void OnHide()
  73. {
  74. }
  75. private void WaitAutoEnd(object param = null)
  76. {
  77. this.Hide();
  78. if (count == totalCount)
  79. {
  80. ViewManager.Show<GetSuitItemVIew>(suitID);
  81. }
  82. else
  83. {
  84. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  85. }
  86. Timers.inst.Remove(WaitAutoEnd);
  87. }
  88. }
  89. }