public ConnectionStateMachine(MixedManager game) { _game = game; var startState = new GameStartState(this, _game); var connectingState = new GameConnectingState(this, _game); var connectedState = new GameConnectedState(this, _game); var disconnectedState = new GameDisconnectedState(this, _game); var roomState = new GameRoomState(this, _game); var stateList = new Dictionary <ConnectionFSMStateEnum.StateEnum, IFsmState> { { ConnectionFSMStateEnum.StateEnum.START, startState }, { ConnectionFSMStateEnum.StateEnum.CONNECTING, connectingState }, { ConnectionFSMStateEnum.StateEnum.CONNECTED, connectedState }, { ConnectionFSMStateEnum.StateEnum.DISCONNECTED, disconnectedState }, { ConnectionFSMStateEnum.StateEnum.ROOM, roomState }, }; SetStates(stateList); var allowedTransitions = new Dictionary <ConnectionFSMStateEnum.StateEnum, IList <ConnectionFSMStateEnum.StateEnum> >(); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.START, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.CONNECTING, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.CONNECTING, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.CONNECTED, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.CONNECTED, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.ROOM, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.DISCONNECTED, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, }); allowedTransitions.Add(ConnectionFSMStateEnum.StateEnum.ROOM, new List <ConnectionFSMStateEnum.StateEnum> { ConnectionFSMStateEnum.StateEnum.START, }); SetTransitions(allowedTransitions); }
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); }