SuitItemView.cs 2.8 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 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. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_topEffect, "ui_LuckyBox", "SJJD_CradUp");
  41. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_probarEffect, "ui_LuckyBox", "SJJD_CradUP_once");
  42. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_downEffect, "ui_LuckyBox", "SJJD_CradDown");
  43. }
  44. protected override void OnShown()
  45. {
  46. base.OnShown();
  47. if (this.viewData != null) {
  48. suitID = (int)(this.viewData as object[])[0];
  49. countSuitId = (int)(this.viewData as object[])[1];
  50. }
  51. UpdateView();
  52. }
  53. private void UpdateView()
  54. {
  55. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  56. count = count - countSuitId;
  57. if (suitID > 0)
  58. {
  59. SuitCfg suitCfg = SuitCfgArray.Instance.GetCfg(suitID);
  60. _ui.m_txtName.text = "套装·" + suitCfg.name;
  61. _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.res);
  62. }
  63. _ui.m_probar.max = totalCount;
  64. _ui.m_probar.value = count;
  65. _ui.m_t_open.Play();
  66. }
  67. private void OnClickBg()
  68. {
  69. if(!GetSuitItemController.isAuto)
  70. {
  71. if (count == totalCount)
  72. {
  73. ViewManager.Show<GetSuitItemVIew>(suitID);
  74. }
  75. this.Hide();
  76. EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  77. }
  78. }
  79. protected override void OnHide()
  80. {
  81. }
  82. }
  83. }