Frame/Assets/Scripts/Game.cs

66 lines
2.0 KiB
C#
Raw Normal View History

2024-04-02 18:17:57 +08:00
using System;
2024-04-03 14:38:44 +08:00
using Cysharp.Threading.Tasks;
2024-04-02 18:17:57 +08:00
using UnityEngine;
namespace Game
{
public class Game : MonoBehaviour
{
private UIManager _uiManager;
private ResourceManager _resourceManager;
2024-04-03 17:46:56 +08:00
private ProcedureManager _procedureManager;
2024-04-02 18:17:57 +08:00
[SerializeField] private LoadType _loadType = LoadType.Editor;
[SerializeField] private float time;
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
_uiManager = new UIManager();
_resourceManager = new ResourceManager();
2024-04-03 17:46:56 +08:00
this._procedureManager = new ProcedureManager();
2024-04-02 18:17:57 +08:00
_resourceManager.Init();
_uiManager.Init();
2024-04-03 17:46:56 +08:00
this._procedureManager.Init();
2024-04-03 18:07:05 +08:00
ProcedureBase[] procedureBases = new ProcedureBase[]
{
new LoadingGameSceneProcedure(), new GameSceneLogicProcedure()
};
this._procedureManager.AddProcedure(procedureBases);
2024-04-02 18:17:57 +08:00
}
private void Start()
{
2024-04-03 14:38:44 +08:00
UniTask.Create(
async () =>
{
await _resourceManager.InitLoadModeAsync(_loadType);
// var loadingGameSceneUI = UIManager.Instance.CreateUI(UIType.LoadingGameSceneUI);
// UIManager.Instance.ShowUI(UIType.LoadingGameSceneUI);
2024-04-03 17:46:56 +08:00
// await this._resourceManager.LoadSceneAsync(SceneType.Game.ToString());
// EventManager.Instance.FireNow(this,new LoadingGameSceneFinishEventArgs(true));
this._procedureManager.StartProcedure(ProcedureType.LoadingGameSceneProcedure);
2024-04-03 14:38:44 +08:00
return "11";
});
2024-04-02 18:17:57 +08:00
}
private void Update()
{
time += Time.deltaTime;
_resourceManager.Update(time);
_uiManager.Update(time);
}
private void OnDestroy()
{
_resourceManager.Dispose();
_uiManager.Dispose();
}
}
}