SuitItemView.cs 2.9 KB

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