RoleLvUpView.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_sj", "SJ",
  79. onComplete: (effect) =>
  80. {
  81. if (effect != null)
  82. {
  83. _effectUI1 = effect;
  84. }
  85. });
  86. //升级成功特效上层
  87. EffectUIPool.CreateEffectUI(_ui.m_holderTitleUp, "ui_sj", "SJ_top_number",
  88. onComplete: (effect) =>
  89. {
  90. if (effect != null)
  91. {
  92. _effectUI2 = effect;
  93. }
  94. });
  95. //等级特效
  96. EffectUIPool.CreateEffectUI(_ui.m_holderNumber, "ui_sj", "SJ_Number",
  97. onComplete: (effect) =>
  98. {
  99. if (effect != null)
  100. {
  101. _effectUI3 = effect;
  102. }
  103. });
  104. }
  105. }
  106. }