123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- 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);
- if (GameGlobal.isOfflineVisitor)
- {
- _ui.m_btnLogout.visible = false;
- }
- else
- {
- _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 (GameGlobal.isOfflineVisitor)
- {
- LoginProxy.LoginAsVisitor();
- }
- else
- {
- if (!GameController.CheckLoginCache(true))
- {
- ViewManager.Show<LoginInputView>();
- }
- }
- }
- private void OnClickBtnLogout()
- {
- _ui.m_btnLogout.visible = false;
- GameController.Logout();
- ViewManager.Show<LoginInputView>();
- }
- }
- }
|