diff --git a/Forest/Assets/Scripts/Framework/Event/Events.cs b/Forest/Assets/Scripts/Framework/Event/Events.cs index 35a1c1a..21e093c 100644 --- a/Forest/Assets/Scripts/Framework/Event/Events.cs +++ b/Forest/Assets/Scripts/Framework/Event/Events.cs @@ -22,6 +22,7 @@ namespace Framework.Event HideGfx, ShowGfx, AddTime, + LoadingEnd, } } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Framework/UI/UIManager.cs b/Forest/Assets/Scripts/Framework/UI/UIManager.cs index 5569ddf..67fd871 100644 --- a/Forest/Assets/Scripts/Framework/UI/UIManager.cs +++ b/Forest/Assets/Scripts/Framework/UI/UIManager.cs @@ -281,10 +281,10 @@ namespace Framework.UI _WindowMeta(UIConstants.UIScore, UIWindowLayer.PopupTips); _WindowMeta(UIConstants.UISyncTip, UIWindowLayer.PopupTips); _WindowMeta(UIConstants.UIUserAgreement, UIWindowLayer.PopupTips); + _WindowMeta(UIConstants.UILogin, UIWindowLayer.PopupTips); _WindowMeta(UIConstants.UIShop, UIWindowLayer.Normal); _WindowMeta(UIConstants.UILevelPanel, UIWindowLayer.Normal); - _WindowMeta(UIConstants.UILogin, UIWindowLayer.Normal); _WindowMeta(UIConstants.UIADPOPUP, UIWindowLayer.Normal); _WindowMeta(UIConstants.UIBuyGoods, UIWindowLayer.Normal); _WindowMeta(UIConstants.UIWinPanel, UIWindowLayer.Normal); diff --git a/Forest/Assets/Scripts/Gameplay/Game/GameStateStart.cs b/Forest/Assets/Scripts/Gameplay/Game/GameStateStart.cs index 94334c4..38b6071 100644 --- a/Forest/Assets/Scripts/Gameplay/Game/GameStateStart.cs +++ b/Forest/Assets/Scripts/Gameplay/Game/GameStateStart.cs @@ -26,6 +26,7 @@ namespace Gameplay.Game public void OnExit() { UIManager.Instance.CloseAllUI(true); + //TODO 特效 GfxManager.Instance.ReturnGfxObj("gfx_character", true); GfxManager.Instance.ReturnGfxObj("gfx_selectlevel", true); } diff --git a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs index e331681..1316a83 100644 --- a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs +++ b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/GameStartLoadingExecutor.cs @@ -9,6 +9,7 @@ using Gameplay.Manager; using Framework.Manager; using Framework.Constants; using Cysharp.Threading.Tasks; +using UnityEngine; namespace Gameplay.LoadingExecutor { @@ -45,6 +46,7 @@ namespace Gameplay.LoadingExecutor private async UniTask InitGfx() { + //TODO 加载特效 await GfxManager.Instance.PreLoadGfx("gfx_character"); await GfxManager.Instance.PreLoadGfx("gfx_selectlevel"); } @@ -53,19 +55,16 @@ namespace Gameplay.LoadingExecutor { await UIManager.Instance.OpenWindow(_windowPos); UIRoot.Instance.BgDestroy(); + + //用户协议 -> 登录 -> 数据同步 + if (AppInfoManager.Instance.UpdateConfirm) + await UIManager.Instance.OpenWindow(UIConstants.UISyncTip); - EventManager.Instance.Send(EventManager.EventName.ShowGfx); - BIManager.Instance.TrackEventOnce(EventFirst.fte_loading_end); + if (!AppInfoManager.Instance.CheckLogin() && !LoginManager.Instance.ShowLogin) + await UIManager.Instance.OpenWindow(UIConstants.UILogin); - if (!UnityEngine.PlayerPrefs.HasKey(LevelConstants.FirstLaunch)) + if (!PlayerPrefs.HasKey(LevelConstants.FirstLaunch)) await UIManager.Instance.OpenWindow(UIConstants.UIUserAgreement); - else - { - if (!AppInfoManager.Instance.CheckLogin() && !LoginManager.Instance.ShowLogin) - { - await UIManager.Instance.OpenWindow(UIConstants.UILogin); - } - } } private async UniTask PreLoadSelectLevel() @@ -81,6 +80,8 @@ namespace Gameplay.LoadingExecutor protected override void _OnEnd() { + EventManager.Instance.Send(EventManager.EventName.LoadingEnd); + BIManager.Instance.TrackEventOnce(EventFirst.fte_loading_end); } } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/UILoadingController.cs b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/UILoadingController.cs index 16b725f..e5ff6f2 100644 --- a/Forest/Assets/Scripts/Gameplay/LoadingExecutor/UILoadingController.cs +++ b/Forest/Assets/Scripts/Gameplay/LoadingExecutor/UILoadingController.cs @@ -61,8 +61,8 @@ public class UILoadingController : UIWindow if (num >= 100f) { await UniTask.NextFrame(); - onLoadingEnd?.Invoke(); HideWindow(); + onLoadingEnd?.Invoke(); } } diff --git a/Forest/Assets/Scripts/Gameplay/UI/Other/UILoginPanelController.cs b/Forest/Assets/Scripts/Gameplay/UI/Other/UILoginPanelController.cs index 02336f4..8ce0723 100644 --- a/Forest/Assets/Scripts/Gameplay/UI/Other/UILoginPanelController.cs +++ b/Forest/Assets/Scripts/Gameplay/UI/Other/UILoginPanelController.cs @@ -13,6 +13,7 @@ public class UILoginPanelController : UIWindow { private string _imgName; private bool _needHideGfx; + private bool _openWithSetting; private bool _showFailTips; private GameObject _btnClose; private GameObject _quickEnter; @@ -33,18 +34,9 @@ public class UILoginPanelController : UIWindow #if !UNITY_IOS FindObj("Bg_Login/Btn/Btn_Apple").gameObject.SetActive(false); #endif - _imgName = StringManager.CurLanguage == StringManager.LanguageType.CN - ? "Bg_Login/Img_Title_CN" - : "Bg_Login/Img_Title_EN"; - FindObj(_imgName).gameObject.SetActive(true); + ChangeLanguage(); } - - private void OnDestroy() - { - EventManager.Instance.Unregister(EventManager.EventName.LoginFail, LoginFail); - EventManager.Instance.Unregister(EventManager.EventName.RefreshLanguage, ChangeLanguage); - } - + protected override void OnOpenWindow(object data) { BIManager.Instance.TrackEvent(Event.show_login); @@ -52,13 +44,15 @@ public class UILoginPanelController : UIWindow EventManager.Instance.Send(EventManager.EventName.HideGfx); _rawImageGaussianBlurMask.texture = CommonUIUtils.RenderTexture; _needHideGfx = data != null && (bool)data; - _btnClose.SetActive(_needHideGfx); - _quickEnter.SetActive(!_needHideGfx); + _openWithSetting = data != null && (bool)data; + _btnClose.SetActive(_openWithSetting); + _quickEnter.SetActive(!_openWithSetting); } private void ChangeLanguage() { - FindObj(_imgName).gameObject.SetActive(false); + if (_imgName != null) + FindObj(_imgName).gameObject.SetActive(false); _imgName = StringManager.CurLanguage == StringManager.LanguageType.CN ? "Bg_Login/Img_Title_CN" : "Bg_Login/Img_Title_EN"; @@ -117,16 +111,22 @@ public class UILoginPanelController : UIWindow CloseWin(); } - private void CloseWin() + private async void CloseWin() { CloseWindow(); if (AppInfoManager.Instance.UpdateConfirm) { - UIManager.Instance.OpenWindow(UIConstants.UISyncTip, _needHideGfx); + await UIManager.Instance.OpenWindow(UIConstants.UISyncTip, _needHideGfx); } else if (!_needHideGfx) { EventManager.Instance.Send(EventManager.EventName.ShowGfx); } } + + private void OnDestroy() + { + EventManager.Instance.Unregister(EventManager.EventName.LoginFail, LoginFail); + EventManager.Instance.Unregister(EventManager.EventName.RefreshLanguage, ChangeLanguage); + } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Gameplay/UI/Other/UISyncTipController.cs b/Forest/Assets/Scripts/Gameplay/UI/Other/UISyncTipController.cs index 7be7299..8ad32c7 100644 --- a/Forest/Assets/Scripts/Gameplay/UI/Other/UISyncTipController.cs +++ b/Forest/Assets/Scripts/Gameplay/UI/Other/UISyncTipController.cs @@ -19,11 +19,13 @@ public class UISyncTipController : UIWindow _content = FindObj("SyncPanel/Txt_Data").GetComponent(); BindButton("SyncPanel/SyncBtn/Btn_Remote", SyncRemoteData); BindButton("SyncPanel/SyncBtn/Btn_Local", SyncLocalData); - BindButton("SyncPanel/Btn_Close", () => - { - BIManager.Instance.TrackEvent(Event.sync_cancel); - CloseUI(); - }); + BindButton("SyncPanel/Btn_Close", Close); + } + + private void Close() + { + BIManager.Instance.TrackEvent(Event.sync_cancel); + CloseUI(); } private void CloseUI() diff --git a/Forest/Assets/Scripts/Gameplay/UI/Other/UIUserAgreementController.cs b/Forest/Assets/Scripts/Gameplay/UI/Other/UIUserAgreementController.cs index e7dc7ff..a8db9e6 100644 --- a/Forest/Assets/Scripts/Gameplay/UI/Other/UIUserAgreementController.cs +++ b/Forest/Assets/Scripts/Gameplay/UI/Other/UIUserAgreementController.cs @@ -4,7 +4,6 @@ using Framework.UI; using UnityEngine.UI; using Framework.Event; using Framework.Constants; -using Gameplay.Login; public class UIUserAgreementController : UIWindow { @@ -14,22 +13,8 @@ public class UIUserAgreementController : UIWindow protected override void OnAwake() { _rawImageGaussianBlurMask = GetComponent("GaussianBlurMask"); - BindButton("Img_User/Btn_Txt_Link", () => Application.OpenURL(Constants.AgreementUrl)); - BindButton("Img_User/Btn_Agree", () => - { - CloseWindow(); - if (!AppInfoManager.Instance.CheckLogin() && !LoginManager.Instance.ShowLogin) - { - UIManager.Instance.OpenWindow(UIConstants.UILogin); - } - else - { - UIManager.Instance.OpenWindow(UIConstants.UISyncTip); - } - - UnityEngine.PlayerPrefs.SetInt(LevelConstants.FirstLaunch, 1); - BIManager.Instance.TrackEventOnce(cfg.BI.EventFirst.fte_privacy_agree); - }); + BindButton("Img_User/Btn_Txt_Link", OpenURL); + BindButton("Img_User/Btn_Agree", OnAgree); _imgName = StringManager.CurLanguage == StringManager.LanguageType.CN ? "Img_User/Img_Icon_CN" : "Img_User/Img_Icon_EN"; @@ -41,4 +26,17 @@ public class UIUserAgreementController : UIWindow EventManager.Instance.Send(EventManager.EventName.HideGfx); _rawImageGaussianBlurMask.texture = CommonUIUtils.RenderTexture; } + + private void OpenURL() + { + Application.OpenURL(Constants.AgreementUrl); + } + + private void OnAgree() + { + CloseWindow(); + + UnityEngine.PlayerPrefs.SetInt(LevelConstants.FirstLaunch, 1); + BIManager.Instance.TrackEventOnce(cfg.BI.EventFirst.fte_privacy_agree); + } } \ No newline at end of file diff --git a/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIMainPanelController.cs b/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIMainPanelController.cs index d49d4c3..e25480e 100644 --- a/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIMainPanelController.cs +++ b/Forest/Assets/Scripts/Gameplay/UI/StartPanel/UIMainPanelController.cs @@ -14,32 +14,43 @@ using Constants = Framework.Constants.Constants; public class UIMainPanelController : UIWindow { private string _imgName; - private string _gfxCharacterPath; private GameObject _gfxCharacter; + private bool _otherPanel; protected override void OnAwake() { - _gfxCharacterPath = string.Format(Constants.GfxPath, "gfx_character"); - EventManager.Instance.Register(EventManager.EventName.RefreshLanguage, ChangeLanguage); - EventManager.Instance.Register(EventManager.EventName.ShowGfx, InitGfx); - EventManager.Instance.Register(EventManager.EventName.HideGfx, HideGfx); + RegisterEvent(); + ChangeLanguage(); + BindButton("Bg_MainPanel/Btn_Challenge", OnEnterLevel); BindButton("Bg_MainPanel/Btn_Option", OnSelectLevel); - BindButton("Bg_MainPanel/UI_LiuHaiTop/Btn_Setting", () => - { - CommonUIUtils.CaptureScreenshot(); - BIManager.Instance.TrackEvent(Event.click_setting); - UIManager.Instance.OpenWindow(UIConstants.UISettingPanel); - }); + BindButton("Bg_MainPanel/UI_LiuHaiTop/Btn_Setting", OpenSettingPanel); BindButton("Bg_MainPanel/UI_LiuHaiTop/Btn_Shop", OpenShop); - _imgName = StringManager.CurLanguage == StringManager.LanguageType.CN - ? "Bg_MainPanel/UI_LiuHaiTop/Img_Title_CN" - : "Bg_MainPanel/UI_LiuHaiTop/Img_Title_EN"; - FindObj(_imgName).gameObject.SetActive(true); CommonUIUtils.CaptureScreenshot(); } + private void Start() + { + OnStart("Bg_MainPanel/"); + } + + protected override void OnCloseWindow(bool destroy = false) + { + //TODO 特效 + HideGfx(); + } + + private void CheckOtherPanel() + { + if (UIManager.Instance.IsWindowStay(UIConstants.UILogin) || + UIManager.Instance.IsWindowStay(UIConstants.UISyncTip) || + UIManager.Instance.IsWindowStay(UIConstants.UIUserAgreement)) + _otherPanel = true; + if (!_otherPanel) + InitGfx(); + } + private async void InitGfx() { _gfxCharacter = await GfxManager.Instance.LoadGfx("gfx_character"); @@ -51,46 +62,39 @@ public class UIMainPanelController : UIWindow GfxManager.Instance.ReturnGfxObj(_gfxCharacter); } - private void Start() + private async void OpenSettingPanel() { - OnStart("Bg_MainPanel/"); + CommonUIUtils.CaptureScreenshot(); + BIManager.Instance.TrackEvent(Event.click_setting); + await UIManager.Instance.OpenWindow(UIConstants.UISettingPanel); } - private void Update() + /// + /// 打开商店 + /// + private async void OpenShop() { - /*if (LoginManager.Instance.NeedSyncData && - (LoginManager.Instance.ShowLogin || LoginManager.Instance.IsLogin) - && UnityEngine.PlayerPrefs.HasKey(LevelConstants.FirstLaunch)) - { - LoginManager.Instance.NeedSyncData = false; - - UIManager.Instance.OpenWindow(UIConstants.UISyncTip, - UIManager.Instance.IsWindowStay(UIConstants.UISettingPanel)); - }*/ - } - - private void OnDisable() - { - if (GfxManager.Instance) - GfxManager.Instance.ReturnGfxObj(_gfxCharacter); - } - - private void OpenShop() - { - UIManager.Instance.OpenWindow(UIConstants.UIShop); + await UIManager.Instance.OpenWindow(UIConstants.UIShop); BIManager.Instance.TrackEvent(Event.open_shop, "UIMainPanel"); BIManager.Instance.TrackEventOnce(EventFirst.fte_open_shop, "UIMainPanel"); } + /// + /// 更换语言 + /// private void ChangeLanguage() { - FindObj(_imgName).gameObject.SetActive(false); + if (_imgName != null) + FindObj(_imgName).gameObject.SetActive(false); _imgName = StringManager.CurLanguage == StringManager.LanguageType.CN ? "Bg_MainPanel/UI_LiuHaiTop/Img_Title_CN" : "Bg_MainPanel/UI_LiuHaiTop/Img_Title_EN"; FindObj(_imgName).gameObject.SetActive(true); } + /// + /// 开始游戏 + /// private void OnEnterLevel() { BIManager.Instance.TrackEvent(Event.click_level_start); @@ -108,18 +112,35 @@ public class UIMainPanelController : UIWindow } } - private void OnSelectLevel() + /// + /// 选择关卡 + /// + private async void OnSelectLevel() { CloseWindow(); BIManager.Instance.TrackEvent(Event.click_level_select); - UIManager.Instance.OpenWindow(UIConstants.UILevelSelect); + await UIManager.Instance.OpenWindow(UIConstants.UILevelSelect); } - private void OnDestroy() + + private void RegisterEvent() { - AssetManager.Instance.Unload(_gfxCharacterPath); + EventManager.Instance.Register(EventManager.EventName.LoadingEnd, CheckOtherPanel); + EventManager.Instance.Register(EventManager.EventName.RefreshLanguage, ChangeLanguage); + EventManager.Instance.Register(EventManager.EventName.ShowGfx, InitGfx); + EventManager.Instance.Register(EventManager.EventName.HideGfx, HideGfx); + } + + private void UnregisterEvent() + { + EventManager.Instance.Unregister(EventManager.EventName.LoadingEnd, CheckOtherPanel); EventManager.Instance.Unregister(EventManager.EventName.RefreshLanguage, ChangeLanguage); EventManager.Instance.Unregister(EventManager.EventName.ShowGfx, InitGfx); EventManager.Instance.Unregister(EventManager.EventName.HideGfx, HideGfx); } + + private void OnDestroy() + { + UnregisterEvent(); + } } \ No newline at end of file