SuitItemView.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. if (this.viewData != null) {
  49. suitID = (int)(this.viewData as object[])[0];
  50. countSuitId = (int)(this.viewData as object[])[1];
  51. }
  52. UpdateView();
  53. }
  54. private void UpdateView()
  55. {
  56. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  57. count = count - countSuitId;
  58. if (suitID > 0)
  59. {
  60. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitID);
  61. _ui.m_txtName.text = "套装·" + suitCfg.name;
  62. _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  63. }
  64. _ui.m_probar.max = totalCount;
  65. _ui.m_probar.value = count - 1;
  66. _ui.m_t_open.Play();
  67. _ui.m_probar.TweenValue(count, 0.7f);
  68. }
  69. private void OnClickBg()
  70. {
  71. if(!GetSuitItemController.isAuto)
  72. {
  73. if (count == totalCount)
  74. {
  75. ViewManager.Show<GetSuitItemVIew>(suitID);
  76. }
  77. this.Hide();
  78. //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  79. }
  80. }
  81. protected override void OnHide()
  82. {
  83. _ui.m_probar.max = 0;
  84. _ui.m_probar.value = 0;
  85. }
  86. }
  87. }