79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using Game.Player;
|
|
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
public class Game : MonoBehaviour
|
|
{
|
|
private static Game _game;
|
|
private UIManager _uiManager;
|
|
private ResourceManager _resourceManager;
|
|
private ProcedureManager _procedureManager;
|
|
public PlayerManager _playerManager;
|
|
|
|
[SerializeField] private LoadType _loadType = LoadType.Editor;
|
|
[SerializeField] private float time;
|
|
|
|
public static IProcedureManager procedureManager => _game._procedureManager;
|
|
public static IResourceManager resourceManager => _game._resourceManager;
|
|
public static IUIManager uiManager => _game._uiManager;
|
|
|
|
public static IPlayerManager playerManager => _game._playerManager;
|
|
|
|
private void Awake()
|
|
{
|
|
_game = this;
|
|
DontDestroyOnLoad(this.gameObject);
|
|
AssemblyManager.Initialize();
|
|
|
|
_uiManager = new UIManager();
|
|
_resourceManager = new ResourceManager();
|
|
this._procedureManager = new ProcedureManager();
|
|
this._playerManager = new PlayerManager();
|
|
|
|
_resourceManager.Init();
|
|
_uiManager.Init();
|
|
this._procedureManager.Init();
|
|
this._playerManager.Init();
|
|
|
|
// ProcedureBase[] procedureBases = new ProcedureBase[]
|
|
// {
|
|
// new LoadingGameSceneProcedure(), new GameSceneLogicProcedure()
|
|
// };
|
|
// this._procedureManager.AddProcedure(procedureBases);
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
UniTask.Create(
|
|
async () =>
|
|
{
|
|
await _resourceManager.InitLoadModeAsync(_loadType);
|
|
|
|
// var loadingGameSceneUI = UIManager.Instance.CreateUI(UIType.LoadingGameSceneUI);
|
|
// UIManager.Instance.ShowUI(UIType.LoadingGameSceneUI);
|
|
|
|
// await this._resourceManager.LoadSceneAsync(SceneType.Game.ToString());
|
|
// EventManager.Instance.FireNow(this,new LoadingGameSceneFinishEventArgs(true));
|
|
|
|
this._procedureManager.StartProcedure(ProcedureType.LoadingGameSceneProcedure);
|
|
return "11";
|
|
}).Forget();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
time = Time.deltaTime;
|
|
_resourceManager.Update(time);
|
|
_uiManager.Update(time);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
_resourceManager.Dispose();
|
|
_uiManager.Dispose();
|
|
}
|
|
}
|
|
} |