private void SetupStateChart(StateChart chart) { var playerTurnState = CreateState <PlayerTurnState>(Match3State.PlayerTurn); var swapInProgressState = CreateState <SwapInProgressState>(Match3State.SwapInProgress); var revertSwapInProgressState = CreateState <RevertSwapInProgressState>(Match3State.RevertSwapInProgress); var matchesSearchState = CreateState <MatchesSearchState>(Match3State.MatchesSearch); var fallingState = CreateState <FallingState>(Match3State.MatchesFall); var gameOverState = CreateState <GameOverState>(Match3State.GameOver); var editor = new StateMachineEditor(chart); editor.Initial().Transition().Target(playerTurnState); playerTurnState.Event(BoardStateEvents.StartSwapEvent).Target(swapInProgressState); swapInProgressState.Event(BoardStateEvents.SwapCompleteEvent).Target(matchesSearchState); revertSwapInProgressState.Event(BoardStateEvents.SwapCompleteEvent).Target(playerTurnState); matchesSearchState.Event(BoardStateEvents.RevertSwapEvent).Target(revertSwapInProgressState); matchesSearchState.Event(BoardStateEvents.NoMatchesFoundEvent).Target(playerTurnState); matchesSearchState.Event(BoardStateEvents.MatchesFoundEvent).Target(fallingState); playerTurnState.Event(BoardStateEvents.NoTurnsLeftEvent).Target(gameOverState); fallingState.Event(BoardStateEvents.FallingCompleteEvent).Target(matchesSearchState); gameOverState.Event(BoardStateEvents.ExitBoardEvent).Target(editor.Final()); }
private void SetupStateChart(StateChart chart) { var bootState = new StateVertex(diContainer.Instantiate <BootState>()); var mapState = new StateVertex(diContainer.Instantiate <LevelSelectionState>()); var boardState = new StateVertex(diContainer.Instantiate <BoardState>()); var editor = new StateMachineEditor(chart); editor.Initial().Transition().Target(mapState); bootState.Transition().Target(mapState); mapState.Event(GameStateEvents.StartLevelEvent).Target(boardState); boardState.Event(GameStateEvents.ExitBoardEvent).Target(mapState); mapState.Event(GameStateEvents.DisposedEvent).Target(editor.Final()); }