/// <summary> /// Замена конструктора, процедура инициализации компонента отображения /// </summary> /// <param name="parModelSideProviderComponent">Связанный компонент на стороне модели</param> /// <param name="parLinkedEventsHandler">Связанный обработчик событий отображения</param> public override void InitAndLink( ViewProviderComponent parModelSideProviderComponent, ViewEventsOpenTkHandler parLinkedEventsHandler) { base.InitAndLink(parModelSideProviderComponent, parLinkedEventsHandler); _modelProviderComponent = (MainMenuControlComponent)parModelSideProviderComponent; _modelProviderComponent.OnBecomeActive += RunAppearFromBlackScreen; _modelProviderComponent.OnBecomeActive += OnActivatedPerform; _modelProviderComponent.OnDeactivated += OnDeactivatedPerform; }
/// <summary> /// Сигнал обновления модели /// </summary> /// <param name="parDeltaTime">Время кадра в секундах</param> public override void Update(double parDeltaTime) { base.Update(parDeltaTime); if (IsFirstUpdate) { IsFirstUpdate = false; if (ParentGameObject.LinkedAppModel.GetGameplaySettingsData().IsIntroDisabled) { //пропускаем заставку ToMainMenu(); } else { WatchingCutsceneProviderComponent = ParentGameObject.AddComponent <IntroViewProviderComponent>( ActualLinkedObjectPoolSupportData.LinkedPoolManager .GetObject <IntroViewProviderComponent>(typeof(IntroViewProviderComponent)) .Init(ParentGameObject)); ParentGameObject.LinkedAppModel.GetSoundManager().PlaySfx(EAppSfxAssets.IntroCutscene, false); WatchingCutsceneProviderComponent.OnIntroCutsceneEndedPerform += OnCutsceneEnd; } } else if (_gameStartSignal) { //уничтожаем меню _currentMainMenuControlComponent.MenuClosedEvent -= ApplicationExit; _currentMainMenuControlComponent.OnGameStart -= StartGame; _currentMainMenuControlComponent.DisableAndSendToPool(); _currentMainMenuMainGameObject.DisableAndSendToPool(); _currentMainMenuMainGameObject = null; _currentMainMenuControlComponent = null; Console.WriteLine("Game is starting..."); //переходим к выбранному игровому уровню _currentGameSessionGameObject = ActualLinkedObjectPoolSupportData.LinkedPoolManager .GetObject <GameObject>(typeof(GameObject)).Init(ParentGameObject.LinkedAppModel); _currentGameSessionControlComponent = ActualLinkedObjectPoolSupportData.LinkedPoolManager .GetObject <GameSessionControllerComponent>(typeof(GameSessionControllerComponent)) .Init(_currentGameSessionGameObject, _selectedLevel); _currentGameSessionGameObject.AddComponent(_currentGameSessionControlComponent); _currentGameSessionControlComponent.OnGameSessionEnd += EndGameSession; _gameStartSignal = false; } }
/// <summary> /// Действия по переходу в главное меню игры /// </summary> private void ToMainMenu() { Console.WriteLine("To main menu transition performed!"); WatchingKeyComponent?.DisableAndSendToPool(); ParentGameObject.LinkedAppModel.GetSoundManager().EnsureBgMusicIsPlaying(EAppMusicAssets.MainMenu, true); _currentMainMenuMainGameObject = ActualLinkedObjectPoolSupportData.LinkedPoolManager.GetObject <GameObject>(typeof(GameObject)) .Init(ParentGameObject.LinkedAppModel); _currentMainMenuControlComponent = ActualLinkedObjectPoolSupportData.LinkedPoolManager.GetObject <MainMenuControlComponent>( typeof(MainMenuControlComponent)).Init(_currentMainMenuMainGameObject); _currentMainMenuMainGameObject.AddComponent(_currentMainMenuControlComponent); _currentMainMenuControlComponent.MenuClosedEvent += ApplicationExit; _currentMainMenuControlComponent.OnGameStart += StartGame; _currentMainMenuControlComponent.Activate(); }