Пример #1
0
        private void World_Exit()
        {
            Debugger.Log("Entering log save");
            if (enableLog)
            {
                Debugger.Log("Log is enabled, filename is " + logFileName + ", working directory is " + Environment.CurrentDirectory);

                try
                {
                    using (var zip = new ZipFile())
                    {
                        zip.AddEntry(LogNames.Replay, (name, stream) =>
                        {
                            var writer = new StreamWriter(stream, System.Text.Encoding.UTF8);
                            foreach (var e in log)
                            {
                                writer.WriteLine(JsonConvert.SerializeObject(e));
                            }
                            writer.Close();
                        });
                        zip.AddEntry(LogNames.GameSettings, JsonConvert.SerializeObject(configuration));
                        zip.AddEntry(LogNames.WorldState, JsonConvert.SerializeObject(worldState));
                        zip.Save(logFileName);
                    }
                }
                catch (Exception e)
                {
                    Debugger.AddException(e);
                }
                Debugger.Log("Log is saved");
            }
        }
Пример #2
0
    public static IEnumerator Start(Func <IEnumerator, Coroutine> startCoroutine)
    {
        Time.timeScale   = Constants.TimeScale;
        Debugger.Config  = Settings.Current.Debugging;
        Debugger.Logger += str =>
        {
            Debug.Log(str);
            File.AppendAllText("log.txt", str + "\n");
        };

        Debugger.AddException("**************  UNITY STARTED " + DateTime.Now);
        Application.logMessageReceived += Application_logMessageReceived;

        if (!Directory.Exists(Constants.LogFolderRoot))
        {
            Directory.CreateDirectory(Constants.LogFolderRoot);
        }

        Loader = new Loader();
        Debugger.Log("Loader ready. Starting: adding levels");
        Debugger.Log("======================= Tutorial competition:" + Settings.Current.TutorialCompetitions);

        GameManager = new GameManager();

        serviceServer = new ServiceServer(Constants.ServicePort);
        new Thread(serviceServer.Work).Start();

        yield return(startCoroutine(new DlcLoader(startCoroutine).LoadAllDlc()));

        isStarted = true;
    }
Пример #3
0
 private static void Application_logMessageReceived(string condition, string stackTrace, LogType type)
 {
     if (inException)
     {
         return;
     }
     if (type != LogType.Exception)
     {
         return;
     }
     inException = true;
     try
     {
         Debugger.AddException("Unity exception. Condition +`" + condition + "`, stackTrace: " + stackTrace + "\n\n\n\n");
         Application.Quit();
     }
     catch { }
 }