2024-10-16 00:03:41 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.AudioHandler;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Loader;
|
|
|
|
|
|
using System.OfflineSystem;
|
|
|
|
|
|
using System.StateSystem;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using FJson;
|
|
|
|
|
|
using Framework.Asset;
|
|
|
|
|
|
using Framework.Audio;
|
|
|
|
|
|
using Framework.common;
|
|
|
|
|
|
using Framework.FSMLite;
|
|
|
|
|
|
using Framework.GamePool.manager;
|
|
|
|
|
|
using Framework.Save;
|
|
|
|
|
|
using Framework.Timer;
|
|
|
|
|
|
using Framework.UI;
|
|
|
|
|
|
using Framework.Utils;
|
|
|
|
|
|
using Framework.Utils.Extend;
|
2024-10-21 22:29:53 +08:00
|
|
|
|
using Game;
|
2024-10-16 00:03:41 +08:00
|
|
|
|
using Runtime.ADAggregator;
|
|
|
|
|
|
using StateSystem.Loader;
|
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
using ToffeeHttp.Runtime;
|
|
|
|
|
|
using ToffeeHttp.Runtime.Core;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
using UnityEngine.Rendering;
|
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
using Views;
|
|
|
|
|
|
using Object = UnityEngine.Object;
|
|
|
|
|
|
|
|
|
|
|
|
namespace StateSystem.State
|
|
|
|
|
|
{
|
|
|
|
|
|
public class StateInit : StateMachine<GameGlobalState>
|
|
|
|
|
|
{
|
2024-10-21 22:29:53 +08:00
|
|
|
|
public static bool HasTempGame;
|
|
|
|
|
|
private SceneLoader _sceneLoader;
|
2024-10-16 00:03:41 +08:00
|
|
|
|
protected override void OnEnter (params object[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
CameraEffectUtils.Instance.SetGameCamBlur(0, 0, null);
|
|
|
|
|
|
SceneInit ();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SceneInit ()
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log ("SceneInit");
|
|
|
|
|
|
// return;
|
|
|
|
|
|
//初始化资源管理器,并挂载AlwaysRes下的所有资源
|
|
|
|
|
|
AssetManager.Instance.Rouse ();
|
2024-10-21 10:22:53 +08:00
|
|
|
|
// #if UNITY_EDITOR
|
|
|
|
|
|
// ManagerInit ();
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// #endif
|
|
|
|
|
|
if (SceneManager.GetActiveScene ().name == "SetupScene")
|
2024-10-19 16:46:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
this._sceneLoader = new SceneLoader (SceneName.InitScene, true);
|
|
|
|
|
|
this._sceneLoader.BeginLoad (null, ManagerInit);
|
2024-10-21 22:29:53 +08:00
|
|
|
|
HasTempGame = false;
|
2024-10-19 16:46:07 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ManagerInit ();
|
2024-10-21 22:29:53 +08:00
|
|
|
|
HasTempGame = true;
|
2024-10-19 16:46:07 +08:00
|
|
|
|
}
|
2024-10-16 00:03:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnExit ()
|
|
|
|
|
|
{
|
|
|
|
|
|
// this._sceneLoader.Kill();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected void ManagerInit ()
|
|
|
|
|
|
{
|
|
|
|
|
|
BeginStaticPanel.OnMessage ("系统初始化...");
|
|
|
|
|
|
Input.multiTouchEnabled = false;
|
|
|
|
|
|
GameQualitySettings.SetFPS (90);
|
|
|
|
|
|
FontLoad ();
|
|
|
|
|
|
Debug.Log ("初始化系统模块");
|
|
|
|
|
|
//初始化配置文件系统
|
|
|
|
|
|
RofManagerConfig.Instance.Rouse ();
|
|
|
|
|
|
//ui 层数据初始化
|
|
|
|
|
|
var viewConfig = new IC_AddressabelConfig (); //使用AssetBundle资源管理
|
|
|
|
|
|
// var viewConfig = Resources.Load<IC_Resource_ViewConfig>("Config/ViewConfig"); //使用Resource资源管理
|
|
|
|
|
|
UIManager.Instance.AddConfig (viewConfig);
|
|
|
|
|
|
//存储系统初始化 ,针对Game类型存档特殊处理
|
|
|
|
|
|
var saveConfig = SaveConfig.CreateConfig (SaveManager.Instance.BaseConfig.RootPath);
|
|
|
|
|
|
// var saveConfig = SaveConfig.CreateConfig();
|
|
|
|
|
|
saveConfig.SetDataHandler (new SaveHandlerFileStream ());
|
|
|
|
|
|
// saveConfig.SetDataHandler (new SaveHandlerQuickFileStream ());
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
saveConfig.SetSerializer (new SaveSerializerJson ());
|
|
|
|
|
|
#else
|
|
|
|
|
|
saveConfig.SetSerializer(new SaveSerializerCommonJson());
|
|
|
|
|
|
#endif
|
|
|
|
|
|
SaveManager.Instance.SetConfig (SaveData.Game , saveConfig);
|
|
|
|
|
|
|
|
|
|
|
|
//对象池初始化
|
|
|
|
|
|
GamePoolManager.Instance.Rouse ();
|
|
|
|
|
|
//存档系统初始化
|
|
|
|
|
|
Account.Instance.Rouse ();
|
|
|
|
|
|
//提前唤醒缓动系统驱动
|
|
|
|
|
|
MintAnimation.Core.MintDriveComponentSinge.Instance.ToString ();
|
|
|
|
|
|
//音频管理器初始化
|
|
|
|
|
|
AudioManager.Instance.Init (new AudioSourceHandler (AudioManager._AUDIO_Path)); //使用AssetBundle资源管理
|
|
|
|
|
|
GameManager.Instance.ScriptRegist ();
|
|
|
|
|
|
GameManager.Instance.Inited ();
|
|
|
|
|
|
//激活离线奖励系统
|
|
|
|
|
|
OfflineMgr.Instance.Rouse ();
|
|
|
|
|
|
//初始化系统时间
|
|
|
|
|
|
GameManager.Instance.InitSystemTime (ThirdPartyMgrInit);
|
|
|
|
|
|
Debug.Log ("系统初始化完毕");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ThirdPartyMgrInit ()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.Instance.OpenView (UIPanel.ScreenEffectPanel);
|
|
|
|
|
|
|
|
|
|
|
|
AnalysisEventMgr.Instance.Rouse ();
|
|
|
|
|
|
// var adConfig = AssetManager.Instance.LoadAsset<ADConfig>("Config/ToponAdConfig.asset");
|
|
|
|
|
|
// var toponAdController = new ToponAdController();
|
|
|
|
|
|
// toponAdController.SetListener(GameManager.Instance.OnAdMask , null);
|
|
|
|
|
|
// ADManager.Instance.Init(null , Account.Instance.UserID , adConfig , toponAdController , GameGlobalConfig.Instance.Channel.ToString());
|
|
|
|
|
|
ADManager.Instance.Init(null , Account.Instance.UserID , null , null , GameGlobalConfig.Instance.Channel.ToString());
|
|
|
|
|
|
#if GM
|
|
|
|
|
|
ADManager.Instance.SetTestModel();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
Debug.Log ("三方系统初始化完毕");
|
|
|
|
|
|
ADManager.Instance.GLOBAL_ShowAwardVideoComplete += GameManager.Instance.OnGlobalVideoAdComplete;
|
|
|
|
|
|
OnInited ();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void FontLoad()
|
|
|
|
|
|
{
|
|
|
|
|
|
TMP_Settings.instance = AssetManager.Instance.LoadAlwaysAsset<TMP_Settings>("/FontResource/TMP Settings.asset");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnInited ()
|
|
|
|
|
|
{
|
|
|
|
|
|
GameUpdateMgr.Instance.CreateTimer (1f , () =>
|
|
|
|
|
|
{
|
2024-10-19 16:46:07 +08:00
|
|
|
|
BeginStaticPanel.ReleasePanel ();
|
2024-10-21 22:29:53 +08:00
|
|
|
|
if (HasTempGame)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.stateMachineRunner.OpenState (GameGlobalState.GameRoom);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.stateMachineRunner.OpenState (GameGlobalState.GameHome);
|
|
|
|
|
|
}
|
2024-10-16 00:03:41 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|