RoleInfoView.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using UI.Main;
  2. using static GFGGame.LauncherConfig;
  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. _ui = UI_RoleInfoUI.Create();
  21. this.viewCom = _ui.target;
  22. this.viewCom.Center();
  23. this.modal = true;
  24. _ui.m_txtVersion.text = GameGlobal.version;
  25. _ui.m_btnExit.onClick.Add(OnClickBtnExit);
  26. _ui.m_btnLogout.onClick.Add(OnClickBtnLogout);
  27. _ui.m_btnSound.onClick.Add(OnClickBtnSound);
  28. _ui.m_btnMusic.onClick.Add(OnClickBtnMusic);
  29. _ui.m_btnHelp.onClick.Add(OnClickBtnHelp);
  30. if(LauncherConfig.netType != EnumNetType.LOCAL)
  31. {
  32. _ui.m_btnHelp.visible = false;
  33. }
  34. }
  35. protected override void OnShown()
  36. {
  37. base.OnShown();
  38. _ui.m_txtRoleName.text = RoleDataManager.roleName;
  39. _ui.m_txtLvl.text = "" + RoleDataManager.lvl;
  40. RoleLevelCfg roleLevelCfg = RoleLevelCfgArray.Instance.GetCfg(RoleDataManager.lvl);
  41. if(roleLevelCfg.exp > 0)
  42. {
  43. _ui.m_proBarExp.value = RoleDataManager.exp;
  44. _ui.m_proBarExp.max = roleLevelCfg.exp;
  45. }
  46. else
  47. {
  48. _ui.m_proBarExp.text = "已满级";
  49. }
  50. _ui.m_btnSound.selected = SoundManager.Instance.isOn;
  51. _ui.m_btnMusic.selected = MusicManager.Instance.isOn;
  52. }
  53. protected override void OnHide()
  54. {
  55. base.OnHide();
  56. }
  57. private void OnClickBtnExit()
  58. {
  59. Alert.Show("确认返回登录页吗?")
  60. .SetLeftButton(true)
  61. .SetRightButton(true, "确认", (object data) => {
  62. GameController.QuitToLoginView(false);
  63. });
  64. }
  65. private void OnClickBtnLogout()
  66. {
  67. Alert.Show("确认注销当前账号吗?")
  68. .SetLeftButton(true)
  69. .SetRightButton(true, "确认", (object data) => {
  70. GameController.QuitToLoginView(true);
  71. });
  72. }
  73. private void OnClickBtnSound()
  74. {
  75. SoundManager.Instance.isOn = _ui.m_btnSound.selected;
  76. }
  77. private void OnClickBtnMusic()
  78. {
  79. MusicManager.Instance.isOn = _ui.m_btnMusic.selected;
  80. }
  81. private void OnClickBtnHelp()
  82. {
  83. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  84. }
  85. }
  86. }