2024-10-24 16:16:57 +08:00
|
|
|
|
using System;
|
|
|
|
|
using Cysharp.Threading.Tasks;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using YooAsset;
|
|
|
|
|
using ZC;
|
|
|
|
|
|
|
|
|
|
namespace Unity.Loader
|
|
|
|
|
{
|
|
|
|
|
public class Global : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
private InitializePackage _initializePackage;
|
|
|
|
|
|
|
|
|
|
[SerializeField] EPlayMode playMode;
|
|
|
|
|
[SerializeField] private string packageName = "DefaultPackage";
|
|
|
|
|
|
|
|
|
|
ZCGame zcGame;
|
2024-11-07 20:55:29 +08:00
|
|
|
|
|
2024-10-25 23:16:38 +08:00
|
|
|
|
private float time;
|
2024-10-26 23:50:18 +08:00
|
|
|
|
private GlobalData _globalData;
|
|
|
|
|
|
|
|
|
|
public GlobalData Data => _globalData;
|
2024-10-24 16:16:57 +08:00
|
|
|
|
|
2024-11-07 20:55:29 +08:00
|
|
|
|
// Action
|
2024-11-07 23:51:24 +08:00
|
|
|
|
public static Action<string> updateTime;
|
|
|
|
|
public static Action<string> updateScore;
|
|
|
|
|
public static Action<string> updateProgress;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Transform _objectPool;
|
|
|
|
|
private bool isDisposed;
|
|
|
|
|
private bool isPause;
|
|
|
|
|
private float gameTime;
|
|
|
|
|
|
|
|
|
|
public static Global _global;
|
|
|
|
|
private ObjectManager _objectManager;
|
|
|
|
|
private UIManager _uiManager;
|
|
|
|
|
private ProcedureManager _procedureManager;
|
|
|
|
|
private ResourcesLocalComponent _resourcesLocalComponent;
|
|
|
|
|
|
|
|
|
|
public static Transform ObjectPool => _global._objectPool;
|
|
|
|
|
public static float GameTime => _global.gameTime;
|
|
|
|
|
|
|
|
|
|
public static IObjectManager ObjectManager => _global._objectManager;
|
|
|
|
|
public static IUIManager UIManager => _global._uiManager;
|
|
|
|
|
public static IProcedureManager ProcedureManager => _global._procedureManager;
|
|
|
|
|
public static IResourcesLocalComponent ResourcesLocalComponent => _global._resourcesLocalComponent;
|
|
|
|
|
|
2024-11-07 20:55:29 +08:00
|
|
|
|
|
2024-10-24 16:16:57 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
2024-11-07 23:51:24 +08:00
|
|
|
|
_global = this;
|
2024-10-24 16:16:57 +08:00
|
|
|
|
DontDestroyOnLoad(this.gameObject);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
this._initializePackage = new InitializePackage(playMode, this.packageName, FinishCallback);
|
2024-10-26 23:50:18 +08:00
|
|
|
|
|
|
|
|
|
_globalData = new GlobalData();
|
2024-10-25 23:16:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
time += Time.fixedTime;
|
2024-11-07 22:49:10 +08:00
|
|
|
|
updateTime?.Invoke(_globalData.runTimeStr);
|
2024-10-26 23:50:18 +08:00
|
|
|
|
// Debug.Log($"{_globalData.runTimeStr}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
_globalData.Dispose();
|
2024-10-24 16:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FinishCallback()
|
|
|
|
|
{
|
|
|
|
|
// yoo init finish
|
|
|
|
|
Debug.Log($"yoo init finish {DateTime.Now}");
|
2024-11-07 23:51:24 +08:00
|
|
|
|
|
|
|
|
|
this._objectPool = transform.Find("ObjectPool");
|
|
|
|
|
this.isDisposed = false;
|
|
|
|
|
this.isPause = false;
|
|
|
|
|
|
|
|
|
|
AssemblyManager.Initialize();
|
2024-10-24 16:16:57 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|