Example #1
0
 protected override void OnDispose()
 {
     _mainMenuController?.Dispose();
     _gameController?.Dispose();
     _shedController?.Dispose();
     _rewardController?.Dispose();
     _profilePlayer.CurrentState.UnSubscriptionOnChange(OnChangeGameState);
     base.OnDispose();
 }
Example #2
0
    private void OnChangeGameState(GameState state)
    {
        switch (state)
        {
        case GameState.Start:
            _mainMenuController = new MainMenuController(_placeForUi, _profilePlayer);
            _gameController?.Dispose();
            _shedController?.Dispose();
            break;

        case GameState.Game:
            _gameController = new GameController(_placeForUi, _profilePlayer);
            _mainMenuController?.Dispose();
            break;

        case GameState.Shed:
            _shedController = new ShedController(_placeForUi, _profilePlayer);
            _mainMenuController?.Dispose();
            break;

        case GameState.Reward:
            _rewardController = new RewardController();
            _mainMenuController?.Dispose();
            break;

        case GameState.Exit:
            Application.Quit();
            break;

        default:
            _mainMenuController?.Dispose();
            _gameController?.Dispose();
            _shedController?.Dispose();
            _rewardController?.Dispose();
            break;
        }
    }