SuitItemView.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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(0.7f, 1, WaitAutoEnd);
  55. }
  56. }
  57. private void OnClickBg()
  58. {
  59. if(!GetSuitItemController.isAuto)
  60. {
  61. this.Hide();
  62. if (count == totalCount)
  63. {
  64. ViewManager.Show<GetSuitItemVIew>(suitID);
  65. }
  66. }
  67. }
  68. protected override void OnHide()
  69. {
  70. }
  71. private void WaitAutoEnd(object param = null)
  72. {
  73. this.Hide();
  74. if (count == totalCount)
  75. {
  76. ViewManager.Show<GetSuitItemVIew>(suitID);
  77. }
  78. else
  79. {
  80. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_ANIMATION_WAIT);
  81. }
  82. Timers.inst.Remove(WaitAutoEnd);
  83. }
  84. }
  85. }