| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 | using UnityEngine;using GFGGame;using ET;using System.Threading;using GFGGame.Launcher;public class GameLauncher : MonoBehaviour{    private void Awake()    {        //ET        System.AppDomain.CurrentDomain.UnhandledException += (sender, e) =>        {            Log.Error(e.ExceptionObject.ToString());        };        SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);        DontDestroyOnLoad(gameObject);        ETTask.ExceptionHandler += Log.Error;        Log.ILog = new UnityLogger();        Options.Instance = new Options();        TimeInfo.Instance.TimeZone = 8;    }    // Start is called before the first frame update    void Start()    {        Screen.sleepTimeout = SleepTimeout.NeverSleep;        Application.runInBackground = true;        LauncherConfig.InitScriptCompilation();        FGUILauncher.Init();        LauncherView.Instance.Open();        InitLauncherCfg();    }    /// <summary>    /// 初始化启动器配置    /// </summary>    public void InitLauncherCfg()    {        LauncherView.Instance.SetDesc("正在初始化..");        var url = LauncherConfig.cfgUrl.Replace("{cfgName}", LauncherConfig.cfgName);        HttpTool.Instance.Get(url, (string json) =>        {            LauncherConfig.InitPlatform(json);            LauncherView.Instance.SetDesc("正在初始化...");            //第一个节点必须放在平台配置加载之后            LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);            CheckGameStatus();        });    }    public void CheckGameStatus()    {        if(LauncherConfig.serverStatus == 1)        {            Alert.Show("游戏正在维护中,请稍后再试。")                .SetLeftButton(true, "知道了", (data) => {                    Application.Quit();                });        }        else        {            CheckApkVersion();        }    }    private void CheckApkVersion()    {        LauncherView.Instance.SetDesc("正在校验应用版本...");        var versionTarget = LauncherConfig.apkVersion;        var version = Application.version;        if (VersionUtil.compare(version, versionTarget))        {            DownloadApk();        }        else        {            VersionController.Instance.Init();        }    }    private void DownloadApk()    {        Alert.Show("需要安装新的安装包,请联系研发获取。")                .SetLeftButton(true, "知道了", (data) => {                    Application.Quit();                });    }}
 |