private SimulationSummaryState CreateSimulationSummaryState(SimulationSummary.SimulationSummary simulationSummary) { var input = new SimulationSummaryStateInput(simulationSummary); var state = new SimulationSummaryState(input, simulationSummary); var launchQuestionnaire = _photonClient.CurrentRoom.RoomInfo.customProperties[CustomRoomSettingKeys.GameScenario].ToString() == "SPL3"; var onEndAndLaunchQuestionniareTransition = new OnEventTransition( LaunchQuestionnaireState.StateName, () => launchQuestionnaire); var onEndAndReturnToMenuTransition = new OnEventTransition( MenuState.StateName, () => !launchQuestionnaire); input.ContinueClickedEvent += onEndAndReturnToMenuTransition.ChangeState; input.ContinueClickedEvent += onEndAndLaunchQuestionniareTransition.ChangeState; input.ContinueClickedEvent += _photonClient.CurrentRoom.Leave; state.AddTransitions( onEndAndReturnToMenuTransition, onEndAndLaunchQuestionniareTransition ); return(state); }
private FeedbackState CreateFeedbackState(ITAlertPhotonClient photonClient) { var input = new FeedbackStateInput(photonClient, _director); var state = new FeedbackState(input, photonClient); var onLobbyStateSync = new OnMessageTransition( photonClient, ITAlertChannel.GameState, typeof(LobbyMessage), LobbyState.StateName); var onSendAndSimulationSummaryTransition = new OnEventTransition( SimulationSummaryState.StateName, () => _simulationSummary.HasData); var onSendAndNoSimulationSummaryTransition = new OnEventTransition( MenuState.StateName, () => !_simulationSummary.HasData); input.FeedbackSendClickedEvent += onSendAndSimulationSummaryTransition.ChangeState; input.FeedbackSendClickedEvent += onSendAndNoSimulationSummaryTransition.ChangeState; state.AddTransitions( onLobbyStateSync, onSendAndSimulationSummaryTransition, onSendAndNoSimulationSummaryTransition); return(state); }
private SettingsState CreateSettingsState() { var input = new SettingsStateInput(); var state = new SettingsState(input); var previousStateTransition = new OnEventTransition(MainMenuState.StateName); input.BackClickedEvent += previousStateTransition.ChangeState; state.AddTransitions(previousStateTransition); return(state); }
private ErrorState CreateErrorState() { var input = new ErrorStateInput(); var state = new ErrorState(input); var backClickedTransition = new OnEventTransition(GameState.StateName); input.BackClickedEvent += backClickedTransition.ChangeState; state.AddTransitions(backClickedTransition); return(state); }
private SettingsState CreateSettingsState(ITAlertPhotonClient photonClient) { var input = new SettingsStateInput(); var state = new SettingsState(input); var previousStateTransition = new OnEventTransition(PausedState.StateName); var onFeedbackStateSyncTransition = new OnMessageTransition(photonClient, ITAlertChannel.GameState, typeof(FeedbackMessage), FeedbackState.StateName); input.BackClickedEvent += previousStateTransition.ChangeState; state.AddTransitions(onFeedbackStateSyncTransition, previousStateTransition); return(state); }
private static CreateGameState CreateCreateGameState(ITAlertPhotonClient client, CreateGameController createGameController, ScenarioController scenarioController) { var input = new CreateGameStateInput(client, scenarioController); var state = new CreateGameState(input, createGameController); var joinedRoomTransition = new OnEventTransition(RoomState.StateName); var previousStateTransition = new OnEventTransition(ScenarioListState.StateName); input.JoinedRoomEvent += joinedRoomTransition.ChangeState; input.BackClickedEvent += previousStateTransition.ChangeState; state.AddTransitions(joinedRoomTransition, previousStateTransition); return(state); }
private LobbyState CreateLobbyState(ITAlertPhotonClient photonClient) { var lobbyController = new LobbyController(_photonClient); var lobbyStateInput = new LobbyStateInput(photonClient); var lobbyState = new LobbyState(lobbyStateInput, lobbyController, photonClient); var initializingTransition = new OnMessageTransition(photonClient, ITAlertChannel.GameState, typeof(InitializingMessage), InitializingState.StateName); var toMenuStateTransition = new OnEventTransition(MenuState.StateName); lobbyStateInput.LeaveLobbyClickedEvent += toMenuStateTransition.ChangeState; lobbyState.AddTransitions(initializingTransition, toMenuStateTransition); return(lobbyState); }
private ScenarioListState CreateScenarioListState(ITAlertPhotonClient client, ScenarioController scenarioController) { var input = new ScenarioListStateInput(client, scenarioController); var state = new ScenarioListState(input, scenarioController); var scenarioSelectedTransition = new OnEventTransition(CreateGameState.StateName); var quickMatchTransition = new OnEventTransition(RoomState.StateName); var previousStateTransition = new OnEventTransition(MainMenuState.StateName); scenarioController.ScenarioSelectedSuccessEvent += scenarioSelectedTransition.ChangeState; scenarioController.QuickMatchSuccessEvent += quickMatchTransition.ChangeState; input.BackClickedEvent += previousStateTransition.ChangeState; state.AddTransitions(scenarioSelectedTransition, previousStateTransition, quickMatchTransition); return(state); }
private GamesListState CreateGameListState(ITAlertPhotonClient client) { var gamesListController = new GamesListController(client); var joinGameController = new JoinGameController(_photonClient); var input = new GamesListStateInput(_photonClient, gamesListController); var state = new GamesListState(input, gamesListController, joinGameController); var joinedRoomTransition = new OnEventTransition(RoomState.StateName); var previousStateTransition = new OnEventTransition(MainMenuState.StateName); input.JoinGameSuccessEvent += joinedRoomTransition.ChangeState; input.BackClickedEvent += previousStateTransition.ChangeState; state.AddTransitions(joinedRoomTransition, previousStateTransition); return(state); }
private PausedState CreatePausedState(ITAlertPhotonClient photonClient) { var pausedStateInput = new PausedStateInput(_director); var pausedState = new PausedState(pausedStateInput); var onFeedbackStateSyncTransition = new OnMessageTransition(photonClient, ITAlertChannel.GameState, typeof(FeedbackMessage), FeedbackState.StateName); var toPlayingStateTransition = new OnEventTransition(PlayingState.StateName); var toSettingsStateTransition = new OnEventTransition(SettingsState.StateName); var quitTransition = new OnEventTransition(MenuState.StateName); pausedStateInput.ContinueClickedEvent += toPlayingStateTransition.ChangeState; pausedStateInput.SettingsClickedEvent += toSettingsStateTransition.ChangeState; pausedStateInput.QuitClickedEvent += quitTransition.ChangeState; pausedState.AddTransitions(onFeedbackStateSyncTransition, toPlayingStateTransition, toSettingsStateTransition, quitTransition); return(pausedState); }
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); }
private GameState CreateGameState() { var gameState = new GameState(); var hadExceptionTransition = new OnEventTransition(ErrorState.StateName); // exceptions thrown in the Unity Update loop dont propogate // TODO: firgure out how to catch unmity exceptions and trigger state transition // temporarily catch ui exception from the director ourselves gameState.Exception += GameExceptionHandler.OnException; GameExceptionHandler.HadUnignoredExceptionEvent += hadExceptionTransition.ChangeState; var disconnectedTransition = new OnEventTransition(ErrorState.StateName); gameState.Disconnected += disconnectedTransition.ChangeState; gameState.AddTransitions(hadExceptionTransition, disconnectedTransition); return(gameState); }
private MainMenuState CreateMainMenuState(ITAlertPhotonClient photonClient, ScenarioController scenarioController) { var input = new MenuStateInput(photonClient, scenarioController); var state = new MainMenuState(input); var joinGameTransition = new OnEventTransition(GamesListState.StateName); var createGameTransition = new OnEventTransition(ScenarioListState.StateName); var settingsTransition = new OnEventTransition(SettingsState.StateName); var joinGameSuccessTransition = new OnEventTransition(RoomState.StateName); var quitTransition = new QuitTransition(); input.JoinGameEvent += joinGameTransition.ChangeState; input.CreateGameClickedEvent += createGameTransition.ChangeState; input.SettingsClickedEvent += settingsTransition.ChangeState; input.JoinGameSuccessEvent += joinGameSuccessTransition.ChangeState; input.QuitClickedEvent += quitTransition.Quit; state.AddTransitions(joinGameTransition, createGameTransition, settingsTransition, joinGameSuccessTransition, quitTransition); return(state); }