public FSM_GameFlow(int fsmID) : base(fsmID) { // create state //Init InitState state_Init = new InitState((int)GameFlowState_ID.Init); state_Init.Initialize(this, null, () => { }); //MainMenu MainMenuState state_MainMenu = new MainMenuState((int)GameFlowState_ID.MainMenu); state_MainMenu.Initialize(this, null, () => { }); //SelectDiff SelectDifficultyState state_SelectDiff = new SelectDifficultyState((int)GameFlowState_ID.SelectDiff); state_SelectDiff.Initialize(this, null, () => { }); //GamePlaying GamePlayingState state_GamePlaying = new GamePlayingState((int)GameFlowState_ID.GamePlaying); state_GamePlaying.Initialize(this, null, () => { }); //GameOver GameOverState state_GameOver = new GameOverState((int)GameFlowState_ID.GameOver); state_GameOver.Initialize(this, null, () => { }); //ShowScore ShowScoreState state_ShowScore = new ShowScoreState((int)GameFlowState_ID.ShowScore); state_ShowScore.Initialize(this, null, () => { }); }
public ConnectionStateMachine(ClientManager game) { _game = game; var startState = new GameStartState(this, _game); var playFabLoginState = new GamePlayFabLoginState(this, _game); var playFabRegisterState = new GamePlayFabRegisterState(this, _game); var connectingState = new GameConnectingState(this, _game); var connectedState = new GameConnectedState(this, _game); var disconnectedState = new GameDisconnectedState(this, _game); var resultState = new GameResultState(this, _game); var playingState = new GamePlayingState(this, _game); var stateList = new Dictionary <ConnectionFSMStateEnum.StateEnum, IFsmState> { { ConnectionFSMStateEnum.StateEnum.START, startState }, { ConnectionFSMStateEnum.StateEnum.PLAYFAB_LOGIN, playFabLoginState }, { ConnectionFSMStateEnum.StateEnum.PLAYFAB_REGISTER, playFabRegisterState }, { ConnectionFSMStateEnum.StateEnum.CONNECTING, connectingState }, { ConnectionFSMStateEnum.StateEnum.CONNECTED, connectedState }, { ConnectionFSMStateEnum.StateEnum.DISCONNECTED, disconnectedState }, { ConnectionFSMStateEnum.StateEnum.RESULT, resultState }, { ConnectionFSMStateEnum.StateEnum.PLAYING, playingState }, }; SetStates(stateList); var allowedTransitions = new Dictionary <ConnectionFSMStateEnum.StateEnum, IList <ConnectionFSMStateEnum.StateEnum> >(); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.START, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.PLAYFAB_LOGIN, ConnectionFSMStateEnum.StateEnum.PLAYFAB_REGISTER, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.PLAYFAB_LOGIN, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, ConnectionFSMStateEnum.StateEnum.CONNECTING, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.PLAYFAB_REGISTER, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, ConnectionFSMStateEnum.StateEnum.CONNECTING, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.CONNECTING, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.CONNECTED, ConnectionFSMStateEnum.StateEnum.DISCONNECTED, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.CONNECTED, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.PLAYING, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.DISCONNECTED, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.RESULT, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.PLAYING, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, }); SetTransitions(allowedTransitions); }