12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091 |
- using UnityEngine;
- using FairyGUI;
- using UI.Login;
- namespace GFGGame
- {
- public class LoginView : BaseView
- {
- private UI_LoginUI _ui;
- private GameObject _scenePrefab;
- private GameObject _sceneObject;
- public override void Dispose()
- {
- _ui = null;
- if (_scenePrefab != null)
- {
- GameObject.Destroy(_scenePrefab);
- _scenePrefab = null;
- }
- base.Dispose();
- }
- protected override void Init()
- {
- base.Init();
- packageName = UI_LoginUI.PACKAGE_NAME;
- _ui = UI_LoginUI.Create();
- viewCom = _ui.target;
- isfullScreen = true;
- _scenePrefab = GFGAsset.Load<GameObject>(ResPathUtil.GetPrefabPath("SceneMain"));
- }
- protected override void OnInit()
- {
- base.OnInit();
- _ui.m_txtVersion.text = GameGlobal.version;
- _ui.m_btnNotice.onClick.Add(OnClickBtnNotice);
- _ui.m_btnStart.onClick.Add(OnClickBtnStart);
- _ui.m_btnLogout.onClick.Add(OnClickBtnLogout);
- _ui.m_imgLogo.visible = LauncherConfig.netType != LauncherConfig.EnumNetType.TEMP;
- }
- protected override void OnShown()
- {
- base.OnShown();
- MusicManager.Instance.Play(ResPathUtil.GetMusicPath(ConstMusicName.DEFAULT));
- if (_sceneObject == null)
- {
- _sceneObject = GameObject.Instantiate(_scenePrefab);
- }
- SceneController.UpdateLoginScene(_sceneObject);
- _ui.m_btnLogout.visible = GameController.CheckLoginCache(false);
- if (!_ui.m_btnLogout.visible)
- {
- ViewManager.Show<LoginInputView>();
- }
- }
- protected override void OnHide()
- {
- if (_sceneObject != null)
- {
- GameObject.Destroy(_sceneObject);
- _sceneObject = null;
- }
- base.OnHide();
- }
- private void OnClickBtnNotice()
- {
- ViewManager.Show<NoticeView>();
- }
- private void OnClickBtnStart()
- {
- if (!GameController.CheckLoginCache(true))
- {
- ViewManager.Show<LoginInputView>();
- }
- }
- private void OnClickBtnLogout()
- {
- _ui.m_btnLogout.visible = false;
- GameController.Logout();
- ViewManager.Show<LoginInputView>();
- }
- }
- }
|