/// <summary>
        /// This is where it all begins!
        /// </summary>
        /// <param name="photonPlugin"></param>
        /// <param name="messenger"></param>
        /// <param name="playerManager"></param>
        /// <returns></returns>
        public ITAlertRoomStateController Create(PluginBase photonPlugin,
                                                 Messenger messenger,
                                                 ITAlertPlayerManager playerManager,
                                                 ExceptionHandler exceptionHandler)
        {
            var sugarAnalytics = new AnalyticsServiceAdapter();
            var analytics      = new AnalyticsServiceManager(sugarAnalytics);
            var roomSettings   = new RoomSettings(photonPlugin);

            var exceptionTransition = new EventTransition(ErrorState.StateName);

            exceptionHandler.ExceptionEvent += e => exceptionTransition.ChangeState();

            var lobbyState            = new LobbyState(photonPlugin, messenger, playerManager, roomSettings, analytics);
            var gameStartedTransition = new EventTransition(GameState.StateName);

            lobbyState.GameStartedEvent += gameStartedTransition.ChangeState;
            lobbyState.AddTransitions(gameStartedTransition);

            var gameState = new GameState(photonPlugin, messenger, playerManager, roomSettings, analytics, exceptionHandler);

            gameState.AddTransitions(exceptionTransition);

            var errorState = new ErrorState(photonPlugin, messenger, playerManager, roomSettings, analytics, exceptionHandler);
            var controller = new ITAlertRoomStateController(lobbyState, gameState, errorState);

            gameState.ParentStateController = controller;

            return(controller);
        }
Ejemplo n.º 2
0
        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);
        }