LoginView.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. if (GameGlobal.isOfflineVisitor)
  49. {
  50. _ui.m_btnLogout.visible = false;
  51. }
  52. else
  53. {
  54. _ui.m_btnLogout.visible = GameController.CheckLoginCache(false);
  55. if (!_ui.m_btnLogout.visible)
  56. {
  57. ViewManager.Show<LoginInputView>();
  58. }
  59. }
  60. }
  61. protected override void OnHide()
  62. {
  63. if (_sceneObject != null)
  64. {
  65. GameObject.Destroy(_sceneObject);
  66. _sceneObject = null;
  67. }
  68. base.OnHide();
  69. }
  70. private void OnClickBtnNotice()
  71. {
  72. ViewManager.Show<NoticeView>();
  73. }
  74. private void OnClickBtnStart()
  75. {
  76. if (GameGlobal.isOfflineVisitor)
  77. {
  78. LoginProxy.LoginAsVisitor();
  79. }
  80. else
  81. {
  82. if (!GameController.CheckLoginCache(true))
  83. {
  84. ViewManager.Show<LoginInputView>();
  85. }
  86. }
  87. }
  88. private void OnClickBtnLogout()
  89. {
  90. _ui.m_btnLogout.visible = false;
  91. GameController.Logout();
  92. ViewManager.Show<LoginInputView>();
  93. }
  94. }
  95. }