private PlayingState CreatePlayingState(ITAlertPhotonClient photonClient)
        {
            var playingStateInput = new PlayingStateInput(_photonClient, _director);
            var playingState      = new PlayingState(_director, playingStateInput, photonClient, _simulationSummary);

            var onFeedbackStateSyncTransition = new OnMessageTransition(photonClient, ITAlertChannel.GameState, typeof(FeedbackMessage), FeedbackState.StateName);
            var toFeedbackTransition          = new OnEventTransition(FeedbackState.StateName);
            var toSimulationSummaryTransition = new OnEventTransition(SimulationSummaryState.StateName);
            var toMenuTransition  = new OnEventTransition(MenuState.StateName);
            var toPauseTransition = new OnEventTransition(PausedState.StateName);

            playingStateInput.PauseClickedEvent                       += toPauseTransition.ChangeState;
            playingStateInput.EndGameContinueClickedEvent             += toFeedbackTransition.ChangeState;
            playingStateInput.EndGameOnePlayerContinueClickedEvent    += toSimulationSummaryTransition.ChangeState;
            playingStateInput.EndGameMaxOnePlayerContinueClickedEvent += toMenuTransition.ChangeState;

            playingState.AddTransitions(onFeedbackStateSyncTransition, toPauseTransition, toFeedbackTransition, toSimulationSummaryTransition, toMenuTransition);

            return(playingState);
        }
示例#2
0
        private ITAlertRoomStateController CreateStateController()
        {
            // TODO: handle the lifecyclemanager changestate event in the case of error -> kick players back to lobby.
            var lifecycleStoppedErrorTransition = new LifecycleStoppedTransition(ErrorState.StateName,
                                                                                 ExitCode.Error, ExitCode.Undefined, ExitCode.Abort);

            var lifecycleManager = InitializeSimulationRoot();

            lifecycleManager.Exception += _exceptionHandler.OnException;
            lifecycleManager.Stopped   += lifecycleStoppedErrorTransition.OnLifecycleStopped;

            var initializingState     = new InitializingState(lifecycleManager, PhotonPlugin, Messenger, PlayerManager, RoomSettings, Analytics);
            var initializedTransition = new CombinedPlayersStateTransition(ClientState.Initialized, PlayingState.StateName);

            initializingState.PlayersInitialized += initializedTransition.OnPlayersStateChange;
            initializingState.AddTransitions(initializedTransition, lifecycleStoppedErrorTransition);

            var playingState = new PlayingState(lifecycleManager, PhotonPlugin, Messenger, PlayerManager, RoomSettings, Analytics);
            var lifecycleCompleteTransition = new LifecycleStoppedTransition(FeedbackState.StateName, ExitCode.Complete);

            lifecycleManager.Stopped += lifecycleCompleteTransition.OnLifecycleStopped;
            playingState.AddTransitions(lifecycleCompleteTransition, lifecycleStoppedErrorTransition);

            var feedbackState           = new FeedbackState(lifecycleManager, PhotonPlugin, Messenger, PlayerManager, RoomSettings, Analytics);
            var feedbackStateTransition = new CombinedPlayersStateTransition(ClientState.FeedbackSent, ExitState.StateName);

            feedbackState.PlayerFeedbackSentEvent += feedbackStateTransition.OnPlayersStateChange;
            feedbackState.AddTransitions(feedbackStateTransition);

            var exitState = new ExitState(lifecycleManager, PhotonPlugin, Messenger, PlayerManager, RoomSettings, Analytics);

            var controller = new ITAlertRoomStateController(initializingState, playingState, feedbackState, exitState);

            controller.SetParent(ParentStateController);

            return(controller);
        }