CTT/Unity/Assets/Hotfix/Init.cs

77 lines
2.5 KiB
C#
Raw Normal View History

2021-04-08 20:09:59 +08:00
using System;
using System.Linq;
using System.Reflection;
using ET;
namespace ET
{
public static class InitHotfix
{
#if UNITY
2021-04-08 20:09:59 +08:00
public static async void Start()
#else
public static async void Start(string key, string keyIV, byte[] xorKey)
#endif
2021-04-08 20:09:59 +08:00
{
try
{
#if UNITY
2021-04-08 20:09:59 +08:00
string clientVersion = await GlobalHotfixProtoHelper.GetClintVersion();
if (!clientVersion.Equals(GlobalConfigComponent.Instance.GlobalProto.ClientVersion))
{
Game.EventSystem.Publish(new ET.EventType.ShowMessageBox
{
title = "提示!",
content = $"客户端有更新,请下载最新版客户端{clientVersion}",
action = async (MessageBoxEventId id) =>
{
Game.EventSystem.Publish_Sync(new ET.EventType.Quit());
}
}).Coroutine();
}
if (Define.hasView)
{
Game.EventSystem.Add(Hotfix.instance.hotfix);
Game.EventSystem.Add(Hotfix.instance.hotfixView);
}
else
{
Game.EventSystem.Add(Hotfix.instance.hotfix);
}
#else
await Game.EventSystem.Publish(new ET.EventType.AppStart()
{
key = key,
keyIV = keyIV,
xorKey = xorKey
});
#endif
2021-04-08 20:09:59 +08:00
Game.Scene.AddComponent<NetThreadComponent>();
Game.Scene.AddComponent<OpcodeTypeComponent>();
Game.Scene.AddComponent<MessageDispatcherComponent>();
Game.Scene.AddComponent<ZoneSceneManagerComponent>();
Game.Scene.AddComponent<AIDispatcherComponent>();
2021-04-08 20:09:59 +08:00
2021-04-11 19:50:39 +08:00
ConfigComponent config = Game.Scene.GetOrAddComponent<ConfigComponent>();
2021-04-08 20:09:59 +08:00
Game.Scene.AddComponent<NumericWatcherComponent>();
Game.Scene.AddComponent<WordComponent>();
Scene zoneScene = SceneFactory.CreateZoneScene(1, "Game");
OpcodeHotfixHelper.Init();
Game.EventSystem.Publish(new ET.EventType.AfterCreateZoneScene() {zoneScene = zoneScene}).Coroutine();
2021-04-08 20:09:59 +08:00
}
catch (Exception e)
{
Log.Error(e);
}
}
}
}