RoleInfoView.cs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using ET;
  2. using UI.RoleInfo;
  3. namespace GFGGame
  4. {
  5. public class RoleInfoView : BaseWindow
  6. {
  7. private UI_RoleInfoUI _ui;
  8. public override void Dispose()
  9. {
  10. if (_ui != null)
  11. {
  12. _ui.Dispose();
  13. }
  14. _ui = null;
  15. base.Dispose();
  16. }
  17. protected override void OnInit()
  18. {
  19. base.OnInit();
  20. packageName = UI_RoleInfoUI.PACKAGE_NAME;
  21. _ui = UI_RoleInfoUI.Create();
  22. this.viewCom = _ui.target;
  23. this.viewCom.Center();
  24. this.modal = true;
  25. _ui.m_txtVersion.text = GameGlobal.version;
  26. _ui.m_txtSlogan.maxLength = GlobalCfgArray.globalCfg.maxSloganWordsCount;
  27. _ui.m_btnExit.onClick.Add(OnClickBtnExit);
  28. _ui.m_btnLogout.onClick.Add(OnClickBtnLogout);
  29. _ui.m_btnSound.onClick.Add(OnClickBtnSound);
  30. _ui.m_btnMusic.onClick.Add(OnClickBtnMusic);
  31. _ui.m_btnHelp.onClick.Add(OnClickBtnHelp);
  32. _ui.m_txtSlogan.onFocusOut.Add(OnFocuseOut);
  33. _ui.m_loaChangeName.onClick.Add(OnClickLoaChangeName);
  34. }
  35. protected override void AddEventListener()
  36. {
  37. base.AddEventListener();
  38. EventAgent.AddEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  39. }
  40. protected override void OnShown()
  41. {
  42. base.OnShown();
  43. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  44. _ui.m_txtLvl.text = "" + GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl);
  45. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(GameGlobal.myNumericComponent.GetAsInt(NumericType.Lvl));
  46. if (roleLevelCfg.exp > 0)
  47. {
  48. _ui.m_proBarExp.value = GameGlobal.myNumericComponent.GetAsInt(NumericType.Exp);
  49. _ui.m_proBarExp.max = roleLevelCfg.exp;
  50. }
  51. else
  52. {
  53. _ui.m_proBarExp.text = "已满级";
  54. }
  55. _ui.m_btnSound.selected = SoundManager.Instance.isOn;
  56. _ui.m_btnMusic.selected = MusicManager.Instance.isOn;
  57. _ui.m_txtSlogan.text = RoleDataManager.slogan;
  58. }
  59. protected override void OnHide()
  60. {
  61. base.OnHide();
  62. }
  63. protected override void RemoveEventListener()
  64. {
  65. base.RemoveEventListener();
  66. EventAgent.RemoveEventListener(ConstMessage.CHANGE_ROLE_NAME, UpdateRoleName);
  67. }
  68. private void UpdateRoleName()
  69. {
  70. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  71. }
  72. private void OnClickBtnHelp()
  73. {
  74. if (GameConfig.showGM >= 1)
  75. {
  76. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  77. }
  78. else
  79. {
  80. ViewManager.Show(ViewName.LOG_VIEW);
  81. }
  82. }
  83. private async void OnFocuseOut()
  84. {
  85. _ui.m_txtSlogan.text = await RoleInfoSProxy.ReqModifySlogan(_ui.m_txtSlogan.text);
  86. }
  87. private void OnClickLoaChangeName()
  88. {
  89. ViewManager.Show<ChangeNameView>(null, new object[] { typeof(RoleInfoView).FullName, this.viewData });
  90. }
  91. private void OnClickBtnExit()
  92. {
  93. AlertSystem.Show("确认返回登录页吗?")
  94. .SetLeftButton(true)
  95. .SetRightButton(true, "确认", (object data) =>
  96. {
  97. GameController.QuitToLoginView(false);
  98. });
  99. }
  100. private void OnClickBtnLogout()
  101. {
  102. AlertSystem.Show("确认注销当前账号吗?")
  103. .SetLeftButton(true)
  104. .SetRightButton(true, "确认", (object data) =>
  105. {
  106. GameController.QuitToLoginView(true);
  107. });
  108. }
  109. private void OnClickBtnSound()
  110. {
  111. SoundManager.Instance.isOn = _ui.m_btnSound.selected;
  112. }
  113. private void OnClickBtnMusic()
  114. {
  115. MusicManager.Instance.isOn = _ui.m_btnMusic.selected;
  116. }
  117. }
  118. }