private void SwitchGameState(BaseGameState gameState) { if (_currentGameState != null) { _currentGameState.OnStateSwitched -= CurrentGameState_OnStateSwitched; _currentGameState.OnEventNotification -= _currentGameState_OnEventNotification; _currentGameState.UnloadContent(); } _currentGameState = gameState; _currentGameState.Initialize(Content); _currentGameState.LoadContent(); _currentGameState.OnStateSwitched += CurrentGameState_OnStateSwitched; _currentGameState.OnEventNotification += _currentGameState_OnEventNotification; }
private void SwitchGameState(BaseGameState gameState) { if (_currentGameState != null) { _currentGameState.OnStateSwitched -= CurrentGameState_OnStateSwitched; _currentGameState.OnEventNotification -= _currentGameState_OnEventNotification; _currentGameState.UnloadContent(); } _currentGameState = gameState; _currentGameState.Initialize(Content, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); _currentGameState.LoadContent(); _currentGameState.OnStateSwitched += CurrentGameState_OnStateSwitched; _currentGameState.OnEventNotification += _currentGameState_OnEventNotification; }
public void SwitchState(BaseGameState state) { _state?.Cleanup(); _state = state; _state?.Initialize(); }