LoginView.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using UnityEngine;
  2. using FairyGUI;
  3. using UI.Login;
  4. namespace GFGGame
  5. {
  6. public class LoginView : BaseView
  7. {
  8. private UI_LoginUI _ui;
  9. private GameObject _scenePrefab;
  10. private GameObject _sceneObject;
  11. public override void Dispose()
  12. {
  13. _ui = null;
  14. if (_scenePrefab != null)
  15. {
  16. GameObject.Destroy(_scenePrefab);
  17. _scenePrefab = null;
  18. }
  19. base.Dispose();
  20. }
  21. protected override void Init()
  22. {
  23. base.Init();
  24. packageName = UI_LoginUI.PACKAGE_NAME;
  25. _ui = UI_LoginUI.Create();
  26. viewCom = _ui.target;
  27. isfullScreen = true;
  28. _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
  29. }
  30. protected override void OnInit()
  31. {
  32. base.OnInit();
  33. _ui.m_txtVersion.text = GameGlobal.version;
  34. _ui.m_btnNotice.onClick.Add(OnClickBtnNotice);
  35. _ui.m_btnStart.onClick.Add(OnClickBtnStart);
  36. _ui.m_btnLogout.onClick.Add(OnClickBtnLogout);
  37. _ui.m_imgLogo.visible = LauncherConfig.netType != LauncherConfig.EnumNetType.TEMP;
  38. }
  39. protected override void OnShown()
  40. {
  41. base.OnShown();
  42. MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
  43. if (_sceneObject == null)
  44. {
  45. _sceneObject = GameObject.Instantiate(_scenePrefab);
  46. }
  47. SceneController.UpdateLoginScene(_sceneObject);
  48. _ui.m_btnLogout.visible = GameController.CheckLoginCache(false);
  49. if (!_ui.m_btnLogout.visible)
  50. {
  51. ViewManager.Show<LoginInputView>();
  52. }
  53. }
  54. protected override void OnHide()
  55. {
  56. if (_sceneObject != null)
  57. {
  58. GameObject.Destroy(_sceneObject);
  59. _sceneObject = null;
  60. }
  61. base.OnHide();
  62. }
  63. private void OnClickBtnNotice()
  64. {
  65. ViewManager.Show<NoticeView>();
  66. }
  67. private void OnClickBtnStart()
  68. {
  69. if (!GameController.CheckLoginCache(true))
  70. {
  71. ViewManager.Show<LoginInputView>();
  72. }
  73. }
  74. private void OnClickBtnLogout()
  75. {
  76. _ui.m_btnLogout.visible = false;
  77. GameController.Logout();
  78. ViewManager.Show<LoginInputView>();
  79. }
  80. }
  81. }