141 lines
4.8 KiB
C#
141 lines
4.8 KiB
C#
// #if UNITY_EDITOR
|
|
// #endif
|
|
|
|
using FairyGUI;
|
|
using IgnoreOPS;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
namespace ZooMatch
|
|
{
|
|
public class MainScene : BaseScene
|
|
{
|
|
public override int SceneIdx => 0;
|
|
|
|
|
|
protected override void OnEnter()
|
|
{
|
|
}
|
|
|
|
protected override void OnLeave()
|
|
{
|
|
}
|
|
|
|
protected override void OnSwitchSceneComplete(object param = null)
|
|
{
|
|
|
|
StartUpAppProcess();
|
|
|
|
}
|
|
|
|
private void StartUpAppProcess()
|
|
{
|
|
OnPermanentAssetsInitComplete();
|
|
}
|
|
|
|
private void OnPermanentAssetsInitComplete(object param = null)
|
|
{
|
|
CtrlDispatcher.Instance.AddListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
|
|
var isAssetBundleLoad = false;
|
|
|
|
// SuperApplication.Instance.AddComponent<AppsFlyerObjectScript1>();
|
|
|
|
#if !UNITY_EDITOR && UNITY_IOS
|
|
// MaxADKit.Init();
|
|
#endif
|
|
|
|
#if UNITY_EDITOR
|
|
isAssetBundleLoad = false;
|
|
#else
|
|
isAssetBundleLoad = false;
|
|
#endif
|
|
if (isAssetBundleLoad)
|
|
{
|
|
int value = 0;
|
|
ZooMatchFileKit.GetLocalAssetBundle(
|
|
max => { GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixMax, max + 1); }, () =>
|
|
{
|
|
value++;
|
|
// GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixProgress, value);
|
|
});
|
|
}
|
|
else
|
|
{
|
|
OnInitAsset();
|
|
}
|
|
|
|
AppDispatcher.Instance.AddListener(AppMsg.UI_LoadingInitAsset, OnInitAsset);
|
|
}
|
|
|
|
private void OnLoginSucceed(object param = null)
|
|
{
|
|
CtrlDispatcher.Instance.RemoveListener(CtrlMsg.Login_Succeed, OnLoginSucceed);
|
|
}
|
|
|
|
private void OnInitAsset(object param = null)
|
|
{
|
|
AppDispatcher.Instance.Dispatch(AppMsg.AppManagerRegister);
|
|
AppDispatcher.Instance.Dispatch(AppMsg.InitUIMgr);
|
|
#if UNITY_EDITOR
|
|
NetworkDispatcher.Instance.Dispatch(NetworkMsg.Login);
|
|
#endif
|
|
AppDispatcher.Instance.AddListener(AppMsg.LoginInit, OnLoadingComplete);
|
|
|
|
// PreferencesMgr.Instance.InitPreferences();
|
|
// NetworkDispatcher.Instance.Dispatch(NetworkMsg.GetConfig);
|
|
}
|
|
|
|
private void OnLoadingComplete(object param = null)
|
|
{
|
|
|
|
CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartReady);
|
|
|
|
TimerHelper.mEasy.AddTimer(3.0f, () =>
|
|
{
|
|
AudioManager.Instance.InitDefaultButtonClickSound(AudioConst.UIButtonDefault);
|
|
ModuleManager.Instance.AllModuleGameStart();
|
|
ShowScene();
|
|
SaveingPotHelper.CheckSaveingPot();
|
|
SaveingPotHelper.TestingClearTime();
|
|
if (GameHelper.IsGiftSwitch())
|
|
{
|
|
WebviewManager.Instance.SetFullScreen();
|
|
int flyswitch = ConfigSystem.GetConfig<CommonModel>().flyswitch;
|
|
int propswitch = ConfigSystem.GetConfig<CommonModel>().propswitch;
|
|
|
|
int offset_y = ConfigSystem.GetConfig<CommonModel>().WVOffset[0];
|
|
int offset_y1 = ConfigSystem.GetConfig<CommonModel>().WVOffset[1];
|
|
Debug.Log("barry offset_y: " + offset_y + " offset_y1: " + offset_y1);
|
|
float top_offset = 0;//fgui中的顶部信息的高度
|
|
float buttom_offset = 157;
|
|
if (Screen.safeArea.y != 0)
|
|
{//刘海屏
|
|
top_offset += Screen.safeArea.y;
|
|
}
|
|
WebviewManager.Instance.SetOffset(offset_y, offset_y1);
|
|
WebviewManager.Instance.SetPadding(0, top_offset / GRoot.inst.height, 0, buttom_offset / GRoot.inst.height);
|
|
|
|
WebviewManager.Instance.RefreshUrl();
|
|
// Debug.Log($"flyswitch==1 ------ {flyswitch == 1}");
|
|
// Debug.Log($"propswitch==1 ------ {propswitch == 1}");
|
|
WebviewManager.Instance.setFlyBtnTag(flyswitch == 1);
|
|
WebviewManager.Instance.setRewardBtnTag(propswitch == 1);
|
|
WebviewManager.Instance.SetDarkThough(false);
|
|
WebviewManager.Instance.ShowH5View(false);
|
|
WebviewManager.Instance.SetBtn(ConfigSystem.GetConfig<CommonModel>().propCoord[0], ConfigSystem.GetConfig<CommonModel>().propCoord[1], 60, 60);
|
|
}
|
|
});
|
|
}
|
|
private static bool is_open = false;
|
|
private void ShowScene()
|
|
{
|
|
if (is_open) return;
|
|
is_open = true;
|
|
UICtrlDispatcher.Instance.Dispatch(UICtrlMsg.GameLoginUI_Open);
|
|
}
|
|
|
|
public override void Dispose()
|
|
{
|
|
}
|
|
}
|
|
} |