YanCheng_Metrology/Assets/Scripts/Project/Manager/GameManager.cs

153 lines
4.4 KiB
C#

using System.Runtime.InteropServices.ComTypes;
using UnityEngine;
/// <summary>
/// 统一引用单例类
/// </summary>
public class GameManager : SingletonAutoMono<GameManager>
{
#region
/// <summary>
/// Ui管理类
/// </summary>
public static UIManager UIMgr { get; private set; }
/// <summary>
/// 事件中心
/// </summary>
public static EventCenter EventMgr { get; private set; }
/// <summary>
/// 公共mono
/// </summary>
public static MonoMgr MonoMgr { get; private set; }
/// <summary>
/// 二进制管理类
/// </summary>
public static BinaryManager BinaryMgr { get; private set; }
/// <summary>
/// json管理类
/// </summary>
public static JsonManager JsonMgr { get; private set; }
/// <summary>
/// 场景加载管理类
/// </summary>
public static ScenesManager ScenesMgr { get; private set; }
/// <summary>
/// 资源加载类
/// </summary>
public static ResourcesManager ResourcesMgr { get; private set; }
/// <summary>
/// 音乐音效管理类
/// </summary>
public static MusicManager MusicMgr { get; private set; }
#endregion
#region
/// <summary>
/// 数据管理类
/// </summary>
public static DataManager DataMgr { get; private set; }
/// <summary>
/// 网络接口管理类
/// </summary>
public static NetManager NetMgr { get; private set; }
/// <summary>
/// 实训流程管理类
/// </summary>
public static ProcessManager ProcessMgr { get; private set; }
/// <summary>
/// 报告管理类
/// </summary>
public static ReportManager ReportMgr { get; private set; }
/// <summary>
/// 实训操作管理类
/// </summary>
public static HandsOnTrainingMgr HandsOnTrainingMgr { get; private set; }
#endregion
/// <summary>
/// 初始化
/// </summary>
public void Init()
{
UIMgr = UIManager.Instance;
EventMgr = EventCenter.Instance;
MonoMgr = MonoMgr.Instance;
BinaryMgr = BinaryManager.Instance;
JsonMgr = JsonManager.Instance;
ScenesMgr = ScenesManager.Instance;
ResourcesMgr = ResourcesManager.Instance;
MusicMgr = MusicManager.Instance;
DataMgr = DataManager.Instance;
NetMgr = NetManager.Instance;
ProcessMgr = ProcessManager.Instance;
ReportMgr = ReportManager.Instance;
HandsOnTrainingMgr = HandsOnTrainingMgr.Instance;
UIMgr.ShowPanel<UI_LoadingPanel>(E_UI_Layer.System, (panel) =>
{
print("显示加载页面");
panel.Init();
EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.1f);
//加载本地文件数据
//初始化用户数据 模式 token等必要数据
//读取成功 获取模式 根据模式显示初始化页面
NetMgr.GetConfig((isSuccess) =>
{
if (isSuccess)
{
DataMgr.Init();
//读取成功 获取模式 根据模式显示初始化页面
//是否为考试模式 安全员
if (!true)
{
}
else
{
EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.2f);
//显示UI菜单列表
UIMgr.ShowPanel<UI_SelectModePanel>(E_UI_Layer.Mid, panel =>
{
EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.2f);
panel.Init();
});
//加载场景 /显示UI
ScenesMgr.LoadSceneAsyn("02_MenuScene", () =>
{
//修改本地文件
NetMgr.SaveInfo("1");
EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.5f);
});
}
}
else
{
//读取失败 提示信息并退出应用
}
});
});
}
public void End()
{
//修改本地文件
NetMgr.SaveInfo("0");
//退出应用
Application.Quit();
}
}