/// <summary> /// Конструктор /// </summary> /// <param name="parPlatform">Платформа</param> public GameController(Platform parPlatform) { _enterOfPlayersController = new EnterOfPlayersController(parPlatform); _currentControllerInGameState = _enterOfPlayersController; _enterOfPlayersController.CompleteEnterOfPlayers += OnCompleteEnterOfPlayers; _platform = parPlatform; _currentControllerInGameState.ChangeState += OnChangeState; }
/// <summary> /// Обрабатывает событие завершения ввода игроков /// </summary> /// <param name="parSender">Источник события</param> /// <param name="parE">Параметры события</param> private void OnCompleteEnterOfPlayers(object parSender, CompleteEnterOfPlayersArgs parE) { _platform.UnsubscribeAllEvents(); _gameFieldController = new GameFieldController(parE.Players, _platform); _currentControllerInGameState = _gameFieldController; _currentControllerInGameState.ChangeState += OnChangeState; _enterOfPlayersController = null; }
/// <summary> /// Изменяет состояние приложения /// </summary> /// <param name="parState">Состояние приложения</param> /// <param name="parFactoryOfContollers">Фабрика контроллера</param> private void ChangeState(ApplicationStates parState, FactoryOfContollers parFactoryOfContollers) { _currentState = parState; _currentFactoryOfControllers = parFactoryOfContollers; if (parState != ApplicationStates.Exit) { _currentController = _currentFactoryOfControllers.CreateController(_platform); _currentController.ChangeState += OnChangeState; } else { _platform.Drop(); } }