RoleLvUpView.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. public override void Dispose()
  15. {
  16. EffectUIPool.Recycle(_effectUI1);
  17. _effectUI1 = null;
  18. EffectUIPool.Recycle(_effectUI2);
  19. _effectUI2 = null;
  20. if (_ui != null)
  21. {
  22. _ui.Dispose();
  23. _ui = null;
  24. }
  25. base.Dispose();
  26. }
  27. protected override void OnInit()
  28. {
  29. base.OnInit();
  30. packageName = UI_RoleLvUpUI.PACKAGE_NAME;
  31. _ui = UI_RoleLvUpUI.Create();
  32. this.viewCom = _ui.target;
  33. this.viewCom.Center();
  34. this.modal = true;
  35. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  36. AddEffect();
  37. }
  38. protected override void OnShown()
  39. {
  40. base.OnShown();
  41. oldLvValue = (int)this.viewData;
  42. UpdateView();
  43. }
  44. private void UpdateView()
  45. {
  46. _ui.m_txtLv.text = RoleDataManager.lvl.ToString();
  47. _ui.m_txtLastLv.text = oldLvValue.ToString();
  48. _ui.m_txtCurLv.text = RoleDataManager.lvl.ToString();
  49. int limiteCountAdd = 0;
  50. int powerCount = 0;
  51. for (int i = oldLvValue; i < RoleDataManager.lvl; i++)
  52. {
  53. RoleLevelCfg cfg = RoleLevelCfgArray.Instance.GetCfg(i);
  54. limiteCountAdd += cfg.addPowerLimit;
  55. powerCount += cfg.addPower;
  56. }
  57. _ui.m_com0.target.visible = limiteCountAdd > 0;
  58. _ui.m_com1.target.visible = powerCount > 0;
  59. _ui.m_com0.m_txtCount.text = string.Format("+{0}", limiteCountAdd);
  60. _ui.m_com1.m_txtCount.text = string.Format("+{0}", powerCount);
  61. }
  62. protected override void OnHide()
  63. {
  64. base.OnHide();
  65. string viewName = GuideController.CheckHasRoleLvGuideOpen();
  66. if (viewName != "")
  67. {
  68. // ViewManager.Show(viewName, null, null, true);
  69. }
  70. }
  71. private void AddEffect()
  72. {
  73. //Éý¼¶³É¹¦ÌØÐ§
  74. _effectUI1 = EffectUIPool.CreateEffectUI(_ui.m_holderTitle, "ui_sj", "SJ");
  75. //µÈ¼¶ÌØÐ§
  76. _effectUI2 = EffectUIPool.CreateEffectUI(_ui.m_holderNumber, "ui_sj", "SJ_Number");
  77. }
  78. }
  79. }