2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using ET;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
public static class InitHotfix
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
#if UNITY
|
2021-04-08 20:09:59 +08:00
|
|
|
|
public static async void Start()
|
2021-04-20 00:25:04 +08:00
|
|
|
|
#else
|
|
|
|
|
public static async void Start(string key, string keyIV, byte[] xorKey)
|
|
|
|
|
#endif
|
2021-04-08 20:09:59 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2021-04-20 00:25:04 +08:00
|
|
|
|
#if UNITY
|
2021-04-08 20:09:59 +08:00
|
|
|
|
string clientVersion = await GlobalHotfixProtoHelper.GetClintVersion();
|
|
|
|
|
if (!clientVersion.Equals(GlobalConfigComponent.Instance.GlobalProto.ClientVersion))
|
|
|
|
|
{
|
2021-04-24 17:39:11 +08:00
|
|
|
|
ETTaskCompletionSource tcs = new ETTaskCompletionSource();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.ShowMessageBox
|
|
|
|
|
{
|
|
|
|
|
title = "提示!",
|
|
|
|
|
content = $"客户端有更新,请下载最新版客户端{clientVersion}!",
|
|
|
|
|
action = async (MessageBoxEventId id) =>
|
|
|
|
|
{
|
2021-04-24 17:39:11 +08:00
|
|
|
|
Quit();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
2021-04-24 17:39:11 +08:00
|
|
|
|
});
|
|
|
|
|
await tcs.Task;
|
|
|
|
|
return;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Define.hasView)
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Add(Hotfix.instance.hotfix);
|
|
|
|
|
Game.EventSystem.Add(Hotfix.instance.hotfixView);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Add(Hotfix.instance.hotfix);
|
|
|
|
|
}
|
2021-04-20 00:25:04 +08:00
|
|
|
|
#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>();
|
2021-04-20 00:25:04 +08:00
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
2021-04-20 00:25:04 +08:00
|
|
|
|
Game.EventSystem.Publish(new ET.EventType.AfterCreateZoneScene() {zoneScene = zoneScene}).Coroutine();
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
2021-04-24 17:39:11 +08:00
|
|
|
|
}
|
|
|
|
|
private static void Quit()
|
|
|
|
|
{
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
|
|
|
#else
|
|
|
|
|
UnityEngine.Application.Quit();
|
|
|
|
|
#endif
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|