SuitItemView.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. using cfg.GfgCfg;
  2. using UI.CommonGame;
  3. using FairyGUI;
  4. using UnityEngine;
  5. using UI.LuckyBox;
  6. namespace GFGGame
  7. {
  8. public class SuitItemView : BaseWindow
  9. {
  10. private UI_SuitItemUI _ui;
  11. private int suitID;
  12. private int countSuitId;//当前获得的物品还有多少个相同套装的部件需要展示
  13. private int count = 0;//套装当前拥有的部件数量
  14. private int totalCount = 1;
  15. private EffectUI _effectUI1;
  16. private EffectUI _effectUI2;
  17. private EffectUI _effectUI3;
  18. public override void Dispose()
  19. {
  20. EffectUIPool.Recycle(_effectUI1);
  21. _effectUI1 = null;
  22. EffectUIPool.Recycle(_effectUI2);
  23. _effectUI2 = null;
  24. EffectUIPool.Recycle(_effectUI3);
  25. _effectUI3 = null;
  26. if (_ui != null)
  27. {
  28. _ui.Dispose();
  29. _ui = null;
  30. }
  31. base.Dispose();
  32. }
  33. protected override void OnInit()
  34. {
  35. base.OnInit();
  36. packageName = UI_SuitItemUI.PACKAGE_NAME;
  37. _ui = UI_SuitItemUI.Create();
  38. this.viewCom = _ui.target;
  39. isfullScreen = true;
  40. _ui.m_loaBg.onTouchBegin.Add(OnClickBg);
  41. _ui.m_probar.max = 0;
  42. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_topEffect, "ui_LuckyBox", "SJJD_CradUp");
  43. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_probarEffect, "ui_LuckyBox", "SJJD_CradUP_once");
  44. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_downEffect, "ui_LuckyBox", "SJJD_CradDown");
  45. }
  46. protected override void OnShown()
  47. {
  48. base.OnShown();
  49. _ui.m_loaBg.touchable = false;
  50. if (this.viewData != null) {
  51. suitID = (int)(this.viewData as object[])[0];
  52. countSuitId = (int)(this.viewData as object[])[1];
  53. }
  54. UpdateView();
  55. Timers.inst.Add(0.5f, 1, OnTimerClick);
  56. }
  57. private void UpdateView()
  58. {
  59. DressUpMenuSuitDataManager.GetSuitProgressBySuitId(suitID, out count, out totalCount);
  60. count = count - countSuitId;
  61. if (suitID > 0)
  62. {
  63. SuitCfg suitCfg = CommonDataManager.Tables.TblSuitCfg.GetOrDefault(suitID);
  64. _ui.m_txtName.text = "套装·" + suitCfg.Name;
  65. _ui.m_icon.url = ResPathUtil.GetFieldGuideIconPath(suitCfg.Res);
  66. }
  67. _ui.m_probar.max = totalCount;
  68. _ui.m_probar.value = count - 1;
  69. _ui.m_t_open.Play();
  70. _ui.m_probar.TweenValue(count, 0.7f);
  71. }
  72. private void OnTimerClick(object param)
  73. {
  74. _ui.m_loaBg.touchable = true;
  75. }
  76. private void OnClickBg()
  77. {
  78. if(!GetSuitItemController.isAuto)
  79. {
  80. if (count == totalCount)
  81. {
  82. ViewManager.Show<GetSuitItemVIew>(suitID);
  83. }
  84. this.Hide();
  85. //EventAgent.DispatchEvent(ConstMessage.LUCKY_BOX_SHOW_VIEW_CLOSE);
  86. }
  87. }
  88. protected override void OnHide()
  89. {
  90. _ui.m_probar.max = 0;
  91. _ui.m_probar.value = 0;
  92. Timers.inst.Remove(OnTimerClick);
  93. _ui.m_loaBg.touchable = true;
  94. }
  95. }
  96. }