// #if UNITY_EDITOR // #endif using System.Linq; using FairyGUI; using IgnoreOPS; using SGModule.NetKit; using Unity.VisualScripting; using UnityEngine; namespace BallKingdomCrush { 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(); #if !UNITY_EDITOR && UNITY_ANDROID // MaxADKit.Init(); #endif #if UNITY_EDITOR isAssetBundleLoad = false; #else isAssetBundleLoad = false; #endif if (isAssetBundleLoad) { int value = 0; LegendFileKit.GetLocalAssetBundle( max => { GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixMax, max + 1); }, () => { value++; // GameDispatcher.Instance.Dispatch(GameMsg.UpdateHotFixProgress, value); }); } else { OnInitAsset(); } UnityManager.Instance.DakaiACT(); AppDispatcher.Instance.AddListener(AppMsg.UI_LoadingInitAsset, OnInitAsset); TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfSend); TrackKit.TrackLoginFunnel(LoginFunnelEventType.AfRecv, "success"); } 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) { if (GameHelper.IsGiftSwitch()) { UnityManager.Instance.InitACT(); } //初始化Live数据 PreDownloadManager.InitializeLiveData(); // Debug.Log("OnLoadingComplete------------"); CtrlDispatcher.Instance.Dispatch(CtrlMsg.Game_StartReady); TimerHelper.mEasy.AddTimer(0.5f, () => { AudioManager.Instance.InitDefaultButtonClickSound(AudioConst.UIButtonDefault); ModuleManager.Instance.AllModuleGameStart(); ShowScene(); SaveingPotHelper.CheckSaveingPot(); SaveingPotHelper.TestingClearTime(); if (GameHelper.IsGiftSwitch()) { PreDownloadManager.StartDownloadAlbumsPicture(); //预下载视频 PreDownloadManager.StartDownload(); PreDownloadManager.StartDownloadSecretPicture(); } }); } public 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() { } } }