/// <summary> /// Обработка нажатия клавиш /// </summary> private void ProcessingKeystrokes() { if (Keyboard.Escape) { SoundGame.Stop(); StateOfGame = StateOfGame.Menu; Menu.MenuControl.BringToFront(); Thread.Sleep(100); } else { if (Keyboard.Enter && menu.StateMenu == StateMenu.SaveGame && Level.StateOfLevel == StateOfLevel.Game) { // Сериализация timer.Stop(); var stream = new FileStream("Serialized", FileMode.Create); var formatter = new BinaryFormatter(); formatter.Serialize(stream, level); stream.Close(); menu.StateMenu = StateMenu.Game; StateOfGame = StateOfGame.Menu; Menu.MenuControl.BringToFront(); Thread.Sleep(100); timer.Start(); } else if (Keyboard.Enter && menu.StateMenu == StateMenu.LoadGame && Level.StateOfLevel == StateOfLevel.Game) { // Десериализвция timer.Stop(); level.Clear(); var stream = new FileStream("Serialized", FileMode.Open); var formatter = new BinaryFormatter(); level = formatter.Deserialize(stream) as Level; stream.Close(); menu.StateMenu = StateMenu.Game; StateOfGame = StateOfGame.Menu; Menu.MenuControl.BringToFront(); Thread.Sleep(100); level.InitStaticFild(); timer.Start(); } else if (Keyboard.Enter && StateOfGame == StateOfGame.GameOver) { StateOfGame = StateOfGame.Menu; Menu.MenuControl.BringToFront(); level.DownloadLevel(1); Thread.Sleep(100); } else if (Keyboard.Enter && StateOfGame == StateOfGame.Menu && menu.StateMenu == StateMenu.Game) { StateOfGame = StateOfGame.Game; screenGame.BringToFront(); menu.ResetPosition(); } } }