2024-06-24 17:06:17 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using Game.RayCast;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.Serialization;
|
2024-07-01 14:22:34 +08:00
|
|
|
|
using YooAsset;
|
2024-06-24 17:06:17 +08:00
|
|
|
|
|
|
|
|
|
namespace Game
|
|
|
|
|
{
|
|
|
|
|
public partial class Game : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private static Game _game;
|
|
|
|
|
private GameObject _self => gameObject;
|
|
|
|
|
private UIManager _uiManager;
|
|
|
|
|
private ResourceManager _resourceManager;
|
|
|
|
|
private ProcedureManager _procedureManager;
|
|
|
|
|
private MouseInputManager _mouseInputManager;
|
|
|
|
|
|
2024-07-01 14:22:34 +08:00
|
|
|
|
[SerializeField] private EPlayMode _loadType = EPlayMode.EditorSimulateMode;
|
2024-06-24 17:06:17 +08:00
|
|
|
|
[SerializeField] private float time;
|
|
|
|
|
|
|
|
|
|
public static GameObject self => _game._self;
|
|
|
|
|
public static IProcedureManager procedureManager => _game._procedureManager;
|
|
|
|
|
public static IResourceManager resourceManager => _game._resourceManager;
|
|
|
|
|
public static IUIManager uiManager => _game._uiManager;
|
|
|
|
|
public static IMouseInputManager mouseInputManager => _game._mouseInputManager;
|
|
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_game = this;
|
|
|
|
|
DontDestroyOnLoad(this.gameObject);
|
|
|
|
|
AssemblyManager.Initialize();
|
|
|
|
|
|
2024-07-01 14:22:34 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
// this._loadType = EPlayMode.EditorSimulateMode;
|
|
|
|
|
#elif UNITY_ANDROID|| PLATFORM_ANDROID|| ENABLE_WEBCAM|| UNITY_WEBGL|| UNITY_EDITOR_WIN
|
|
|
|
|
// this._loadType = EPlayMode.HostPlayMode;
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-06-24 17:06:17 +08:00
|
|
|
|
this._uiManager = new UIManager();
|
|
|
|
|
this._resourceManager = new ResourceManager();
|
|
|
|
|
this._procedureManager = new ProcedureManager();
|
|
|
|
|
this._mouseInputManager = new MouseInputManager();
|
|
|
|
|
|
|
|
|
|
this._resourceManager.Init();
|
|
|
|
|
this._uiManager.Init();
|
|
|
|
|
this._procedureManager.Init();
|
|
|
|
|
this._mouseInputManager.Init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
UniTask.Create(
|
|
|
|
|
async () =>
|
|
|
|
|
{
|
|
|
|
|
await _resourceManager.InitLoadModeAsync(this._loadType);
|
|
|
|
|
|
|
|
|
|
// Game.uiManager.CreateUI(UIType.GlobalLogOnlyAppUI, UILayer.High);
|
|
|
|
|
// Game.uiManager.ShowUI(UIType.GlobalLogOnlyAppUI);
|
|
|
|
|
Debug.Log("asset init finish!");
|
|
|
|
|
|
|
|
|
|
this.OnCreateUI();
|
|
|
|
|
|
|
|
|
|
this._procedureManager.StartProcedure(ProcedureType.LoadingGameSceneProcedure);
|
2024-07-01 14:22:34 +08:00
|
|
|
|
// return "11";
|
2024-06-24 17:06:17 +08:00
|
|
|
|
}).Forget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCreateUI()
|
|
|
|
|
{
|
|
|
|
|
Debug.Log("start create ui !");
|
|
|
|
|
|
|
|
|
|
Game.uiManager.CreateUI(UIType.GameUI, AssetsConst.Assets_Res_Prefab_UI_GameUI_prefab, UILayer.Mid);
|
|
|
|
|
|
|
|
|
|
Debug.Log("AddAppLogcreate ui finish !");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
time += Time.deltaTime;
|
|
|
|
|
|
|
|
|
|
this._resourceManager.Update(time);
|
|
|
|
|
this._uiManager.Update(time);
|
|
|
|
|
this._procedureManager.Update(time);
|
|
|
|
|
this._mouseInputManager.Update(this.time);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
this._resourceManager.Dispose();
|
|
|
|
|
this._uiManager.Dispose();
|
|
|
|
|
this._procedureManager.Dispose();
|
|
|
|
|
this._mouseInputManager.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|