RoleLvUpView.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. public override void Dispose()
  13. {
  14. if (_ui != null)
  15. {
  16. _ui.Dispose();
  17. _ui = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void OnInit()
  22. {
  23. base.OnInit();
  24. packageName = UI_RoleLvUpUI.PACKAGE_NAME;
  25. _ui = UI_RoleLvUpUI.Create();
  26. this.viewCom = _ui.target;
  27. this.viewCom.Center();
  28. this.modal = true;
  29. viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
  30. }
  31. protected override void OnShown()
  32. {
  33. base.OnShown();
  34. oldLvValue = (int)this.viewData;
  35. UpdateView();
  36. }
  37. private void UpdateView()
  38. {
  39. _ui.m_txtLv.text = RoleDataManager.lvl.ToString();
  40. _ui.m_txtLastLv.text = oldLvValue.ToString();
  41. _ui.m_txtCurLv.text = RoleDataManager.lvl.ToString();
  42. int limiteCountAdd = 0;
  43. int powerCount = 0;
  44. for (int i = oldLvValue; i < RoleDataManager.lvl; i++)
  45. {
  46. RoleLevelCfg cfg = RoleLevelCfgArray.Instance.GetCfg(i);
  47. limiteCountAdd += cfg.addPowerLimit;
  48. powerCount += cfg.addPower;
  49. }
  50. _ui.m_com0.target.visible = limiteCountAdd > 0;
  51. _ui.m_com1.target.visible = powerCount > 0;
  52. _ui.m_com0.m_txtCount.text = string.Format("+{0}", limiteCountAdd);
  53. _ui.m_com1.m_txtCount.text = string.Format("+{0}", powerCount);
  54. }
  55. protected override void OnHide()
  56. {
  57. base.OnHide();
  58. string viewName = GuideController.CheckHasRoleLvGuideOpen();
  59. if (viewName != "")
  60. {
  61. // ViewManager.Show(viewName, null, null, true);
  62. }
  63. }
  64. }
  65. }