ShanxiKnowledgeBase/SXElectricityInformationAcq.../Assets/Framework/GameLauncher.cs

105 lines
2.7 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Scripts.Runtime.Engine.Engine.Camera;
using UnityEngine;
// 添加游戏开发中常用的游戏模块的命名空间
using MotionFramework;
using MotionFramework.Console;
using MotionFramework.Event;
using MotionFramework.Scripts.Runtime.Engine.Engine.Network.WebRequest;
using MotionFramework.Utility;
using UnityEngine.SceneManagement;
public class GameLauncher : MonoBehaviour
{
public string sceneName;
void Awake()
{
// 初始化框架
MotionEngine.Initialize(this, HandleMotionFrameworkLog);
System.IO.File.WriteAllText(Application.streamingAssetsPath + "/start.ini", "1");
}
void Start()
{
SceneManager.LoadScene(sceneName);
// 创建游戏模块
CreateGameModules();
}
void Update()
{
// 更新框架
MotionEngine.Update();
}
private async void CreateGameModules()
{
//webrequest管理器
MotionEngine.CreateModule<WebRequestManager>();
//工具包
MotionEngine.CreateModule<ToolsPackManager>();
//数据配置文件
MotionEngine.CreateModule<DataConfigManager>();
//流程管理器
MotionEngine.CreateModule<AnimationProcessManager>();
//加载配置信息
MotionEngine.CreateModule<InfoDataManager>();
//加载消息框
MotionEngine.CreateModule<MessageManager>();
//修改模式
MotionEngine.GetModule<DataConfigManager>().SetProcessMode(MotionEngine.GetModule<InfoDataManager>().GetParsedData().SceneModel);
//修改IP
PlayerPrefs.SetString("IP",MotionEngine.GetModule<InfoDataManager>().GetParsedData().APIIP);
//用户信息
this.GetComponent<UserInfoComponent>().Init();
//初始化步骤流程
MotionEngine.GetModule<AnimationProcessManager>().InitializeFirstStep();
//教学模式显示箭头和提示框
if (MotionEngine.GetModule<DataConfigManager>().GetProcessMode() != ProcessMode.Assessment)//HQB 0920
{
this.GetComponent<IndicatorArrowComponent>().Init();
}
}
private void HandleMotionFrameworkLog(ELogLevel logLevel, string log)
{
if (logLevel == ELogLevel.Log)
{
UnityEngine.Debug.Log(log);
}
else if (logLevel == ELogLevel.Error)
{
UnityEngine.Debug.LogError(log);
}
else if (logLevel == ELogLevel.Warning)
{
UnityEngine.Debug.LogWarning(log);
}
else if (logLevel == ELogLevel.Exception)
{
UnityEngine.Debug.LogError(log);
}
else
{
throw new NotImplementedException($"{logLevel}");
}
}
}