RoleLvUpView.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UI.RoleLvUp;
  5. using FairyGUI;
  6. namespace GFGGame
  7. {
  8. public class RoleLvUpView : BaseWindow
  9. {
  10. private UI_RoleLvUpUI _ui;
  11. private int oldLvValue;
  12. private EffectUI _effectUI1;
  13. private EffectUI _effectUI2;
  14. private EffectUI _effectUI3;
  15. public override void Dispose()
  16. {
  17. EffectUIPool.Recycle(_effectUI1);
  18. _effectUI1 = null;
  19. EffectUIPool.Recycle(_effectUI2);
  20. _effectUI2 = null;
  21. EffectUIPool.Recycle(_effectUI3);
  22. _effectUI3 = null;
  23. if (_ui != null)
  24. {
  25. _ui.Dispose();
  26. _ui = null;
  27. }
  28. base.Dispose();
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. packageName = UI_RoleLvUpUI.PACKAGE_NAME;
  34. _ui = UI_RoleLvUpUI.Create();
  35. this.viewCom = _ui.target;
  36. this.viewCom.Center();
  37. this.modal = true;
  38. //viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  39. AddEffect();
  40. }
  41. protected override void OnShown()
  42. {
  43. base.OnShown();
  44. oldLvValue = (int)this.viewData;
  45. UpdateView();
  46. }
  47. private void UpdateView()
  48. {
  49. _ui.m_txtLv.text = RoleDataManager.lvl.ToString();
  50. _ui.m_txtLastLv.text = oldLvValue.ToString();
  51. _ui.m_txtCurLv.text = RoleDataManager.lvl.ToString();
  52. int limiteCountAdd = 0;
  53. int powerCount = 0;
  54. for (int i = oldLvValue; i < RoleDataManager.lvl; i++)
  55. {
  56. RoleLevelCfg cfg = RoleLevelCfgArray.Instance.GetCfg(i);
  57. limiteCountAdd += cfg.addPowerLimit;
  58. powerCount += cfg.addPower;
  59. }
  60. _ui.m_com0.target.visible = limiteCountAdd > 0;
  61. _ui.m_com1.target.visible = powerCount > 0;
  62. _ui.m_com0.m_txtCount.text = string.Format("+{0}", limiteCountAdd);
  63. _ui.m_com1.m_txtCount.text = string.Format("+{0}", powerCount);
  64. }
  65. protected override void OnHide()
  66. {
  67. base.OnHide();
  68. string viewName = GuideController.CheckHasRoleLvGuideOpen();
  69. if (viewName != "")
  70. {
  71. // ViewManager.Show(viewName, null, null, true);
  72. }
  73. }
  74. private void AddEffect()
  75. {
  76. //升级成功特效
  77. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_sj", "SJ");
  78. //升级成功特效上层
  79. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderTitleUp, "ui_sj", "SJ_top_number");
  80. //等级特效
  81. _effectUI3 = EffectUIPool.CreateEffectUI(_ui.m_holderNumber, "ui_sj", "SJ_Number");
  82. }
  83. }
  84. }