130 lines
4.7 KiB
C#
130 lines
4.7 KiB
C#
using System;
|
|
using Cysharp.Threading.Tasks;
|
|
using Game.Boss;
|
|
using Game.Dinosaurs;
|
|
using Game.Pathfinding;
|
|
using Game.Player;
|
|
using Game.RayCast;
|
|
using Game.Room;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Game
|
|
{
|
|
public class GlobalPlayerData
|
|
{
|
|
public string name;
|
|
public long id;
|
|
public float jinBei;
|
|
// ....
|
|
|
|
public GlobalPlayerData(string name, long id, float jinBei)
|
|
{
|
|
this.name = name;
|
|
this.id = id;
|
|
this.jinBei = jinBei;
|
|
}
|
|
}
|
|
|
|
public class Game : MonoBehaviour
|
|
{
|
|
private static Game _game;
|
|
private GameObject _self => gameObject;
|
|
private UIManager _uiManager;
|
|
private ResourceManager _resourceManager;
|
|
private ProcedureManager _procedureManager;
|
|
private SocketManager _socketManager;
|
|
private HttpManager _httpManager;
|
|
|
|
[SerializeField] private LoadType _loadType1 = LoadType.Editor;
|
|
[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 ISocketManager socketManager => _game._socketManager;
|
|
public static IHttpManager httpManager => _game._httpManager;
|
|
public static GlobalPlayerData currentPlayerData;
|
|
|
|
private void Awake()
|
|
{
|
|
_game = this;
|
|
DontDestroyOnLoad(this.gameObject);
|
|
AssemblyManager.Initialize();
|
|
|
|
this._uiManager = new UIManager();
|
|
this._resourceManager = new ResourceManager();
|
|
this._procedureManager = new ProcedureManager();
|
|
this._socketManager = new SocketManager();
|
|
this._httpManager = new HttpManager();
|
|
|
|
this._resourceManager.Init();
|
|
this._uiManager.Init();
|
|
this._procedureManager.Init();
|
|
this._socketManager.Init();
|
|
this._httpManager.Init();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
Application.targetFrameRate = 60;
|
|
QualitySettings.vSyncCount = 2;
|
|
Screen.SetResolution(1080, 1920, true);
|
|
|
|
UniTask.Create(
|
|
async () =>
|
|
{
|
|
await _resourceManager.InitLoadModeAsync(_loadType1);
|
|
|
|
this.OnCreateUI();
|
|
|
|
//#if !UNITY_EDITOR
|
|
// Game.uiManager.ShowUI(UIType.GlobalLogOnlyAppUI);
|
|
//#endif
|
|
|
|
this._procedureManager.StartProcedure(ProcedureType.LoadingHallSceneProcedure);
|
|
return "11";
|
|
}).Forget();
|
|
}
|
|
|
|
private void OnCreateUI()
|
|
{
|
|
Game.uiManager.CreateUI(UIType.GlobalLogOnlyAppUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GlobalLogOnlyAppUI, UILayer.High);
|
|
|
|
CommonHelper.AddAppLog("start create ui !");
|
|
|
|
Game.uiManager.CreateUI(UIType.InputNameUI, AssetConstPath.Assets_GameRes_Prefabs_UI_InputNameUI, UILayer.Mid);
|
|
Game.uiManager.CreateUI(UIType.GameSceneHelpUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GameSceneHelpUI, UILayer.High);
|
|
Game.uiManager.CreateUI(UIType.GameSceneMainUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GameSceneMainUI, UILayer.Low);
|
|
Game.uiManager.CreateUI(UIType.GameSceneResultUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GameSceneResultUI, UILayer.High);
|
|
Game.uiManager.CreateUI(UIType.GameStorePurchaseUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GameStorePurchaseUI, UILayer.Mid);
|
|
Game.uiManager.CreateUI(UIType.HallSceneMainUI, AssetConstPath.Assets_GameRes_Prefabs_UI_HallSceneMainUI, UILayer.Mid);
|
|
Game.uiManager.CreateUI(UIType.HallSceneMallUI, AssetConstPath.Assets_GameRes_Prefabs_UI_HallSceneMallUI, UILayer.Mid);
|
|
Game.uiManager.CreateUI(UIType.GlobalTipsUI, AssetConstPath.Assets_GameRes_Prefabs_UI_GlobalTipsUI, UILayer.High);
|
|
|
|
CommonHelper.AddAppLog("create ui finish !");
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
time = Time.deltaTime;
|
|
|
|
this._resourceManager.Update(time);
|
|
this._uiManager.Update(time);
|
|
this._procedureManager.Update(time);
|
|
this._socketManager.Update(this.time);
|
|
this._httpManager.Update(this.time);
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
this._resourceManager.Dispose();
|
|
this._uiManager.Dispose();
|
|
this._procedureManager.Dispose();
|
|
this._socketManager.Dispose();
|
|
this._httpManager.Dispose();
|
|
}
|
|
}
|
|
} |