private static void TimersStop() { Loger.Log("Client TimersStop b"); if (TimerReconnect != null) { TimerReconnect.Stop(); } TimerReconnect = null; if (Timers != null) { Timers.Stop(); } Timers = null; Loger.Log("Client TimersStop e"); }
/// <summary> /// Инициализация после получения всех данных и уже запущенной игре /// </summary> public static void InitGame() { try { Loger.Log("Client InitGame()"); //Data.ChatsTime = (DateTime.UtcNow + ServerTimeDelta).AddDays(-1); //без этого указания будут получены все сообщения с каналов MainButtonWorker_OC.ShowOnStart(); UpdateWorldController.ClearWorld(); UpdateWorldController.InitGame(); Data.UpdateTime = DateTime.MinValue; UpdateWorld(true); Data.LastServerConnect = DateTime.MinValue; Timers.Add(100, UpdateFastTimer); Timers.Add(500, UpdateChats); Timers.Add(5000, () => UpdateWorld(false)); Timers.Add(10000, PingServer); Timers.Add(60000 * Data.DelaySaveGame, BackgroundSaveGame); TimerReconnect.Add(1000, CheckReconnectTimer); //устанавливаем событие на выход из игры GameExit.BeforeExit = () => { try { Loger.Log("Client BeforeExit "); GameExit.BeforeExit = null; TimersStop(); if (Current.Game == null) { return; } if (!Data.BackgroundSaveGameOff) { Loger.Log($"Client {SessionClientController.My.Login} SaveGameBeforeExit " + SaveFullName); GameDataSaveLoader.SaveGame(SaveName); var content = File.ReadAllBytes(SaveFullName); if (content.Length > 1024) { Data.SaveFileData = content; Data.SingleSave = false; UpdateWorld(false); Loger.Log($"Client {SessionClientController.My.Login} SaveGameBeforeExit OK"); } } SessionClient.Get.Disconnect(); } catch (Exception e) { Loger.Log("Client BeforeExit Exception: " + e.ToString()); throw; } }; } catch (Exception e) { ExceptionUtil.ExceptionLog(e, "Client InitGame Error"); GameExit.BeforeExit = null; TimersStop(); if (Current.Game == null) { return; } SessionClient.Get.Disconnect(); } }