【UI】主界面相关

iOS_release
zhangaotian 2024-06-18 17:53:12 +08:00
parent a50d4fc2dc
commit 8e4ded290f
9 changed files with 117 additions and 93 deletions

View File

@ -22,6 +22,7 @@ namespace Framework.Event
HideGfx,
ShowGfx,
AddTime,
LoadingEnd,
}
}
}

View File

@ -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);

View File

@ -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);
}

View File

@ -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);
}
}
}

View File

@ -61,8 +61,8 @@ public class UILoadingController : UIWindow
if (num >= 100f)
{
await UniTask.NextFrame();
onLoadingEnd?.Invoke();
HideWindow();
onLoadingEnd?.Invoke();
}
}

View File

@ -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);
}
}

View File

@ -19,11 +19,13 @@ public class UISyncTipController : UIWindow
_content = FindObj("SyncPanel/Txt_Data").GetComponent<TextMeshProUGUI>();
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()

View File

@ -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<RawImage>("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);
}
}

View File

@ -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()
/// <summary>
/// 打开商店
/// </summary>
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");
}
/// <summary>
/// 更换语言
/// </summary>
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);
}
/// <summary>
/// 开始游戏
/// </summary>
private void OnEnterLevel()
{
BIManager.Instance.TrackEvent(Event.click_level_start);
@ -108,18 +112,35 @@ public class UIMainPanelController : UIWindow
}
}
private void OnSelectLevel()
/// <summary>
/// 选择关卡
/// </summary>
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();
}
}