RoleLvUpView.cs 2.9 KB

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