using System; using System.Linq; using System.Reflection; using ET; namespace ET { public static class InitHotfix { #if UNITY public static async void Start() #else public static async void Start(string key, string keyIV, byte[] xorKey) #endif { try { #if UNITY string clientVersion = await GlobalHotfixProtoHelper.GetClintVersion(); if (!clientVersion.Equals(GlobalConfigComponent.Instance.GlobalProto.ClientVersion)) { ETTaskCompletionSource tcs = new ETTaskCompletionSource(); Game.EventSystem.Publish(new ET.EventType.ShowMessageBox { title = "提示!", content = $"客户端有更新,请下载最新版客户端{clientVersion}!", action = async (MessageBoxEventId id) => { Quit(); } }); await tcs.Task; return; } 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 Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); ConfigComponent config = Game.Scene.GetOrAddComponent(); Game.Scene.AddComponent(); Game.Scene.AddComponent(); Scene zoneScene = SceneFactory.CreateZoneScene(1, "Game"); OpcodeHotfixHelper.Init(); Game.EventSystem.Publish_Sync(new ET.EventType.AfterCreateZoneScene() {zoneScene = zoneScene}); } catch (Exception e) { Log.Error(e); } } private static void Quit() { #if UNITY_EDITOR UnityEditor.EditorApplication.isPlaying = false; #else UnityEngine.Application.Quit(); #endif } } }