private void DisposeAllControllers()
 {
     _mainMenuController?.Dispose();
     _gameController?.Dispose();
     _fightWindowController?.Dispose();
     _dailyRewardController?.Dispose();
     _startFightController?.Dispose();
 }
Exemple #2
0
    private void OnChangeGameState(GameState state)
    {
        switch (state)
        {
        case GameState.Start:
            _mainMenuController = new MainMenuController(_placeForUi, _profilePlayer);
            _gameController?.Dispose();
            _garageController?.Dispose();
            _startFightController?.Dispose();
            _fightWindowController?.Dispose();
            break;

        case GameState.Garage:
            _garageController = new GarageController(_placeForUi, _profilePlayer, _inventoryModel);
            _mainMenuController?.Dispose();
            _startFightController?.Dispose();
            _fightWindowController?.Dispose();
            break;

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

        case GameState.Fight:
            _fightWindowController = new FightWindowController(_profilePlayer, _placeForUi);
            _mainMenuController?.Dispose();
            _startFightController?.Dispose();
            _gameController?.Dispose();
            break;

        default:
            _mainMenuController?.Dispose();
            _gameController?.Dispose();
            _startFightController?.Dispose();
            _fightWindowController?.Dispose();
            break;
        }
    }
    private void OnChangeGameState(GameState state)
    {
        switch (state)
        {
        case GameState.Start:
            _mainMenuController = new MainMenuController(_placeForUi, _profilePlayer);
            _gameController?.Dispose();
            break;

        case GameState.Game:
            _gameController = new GameController(_placeForUi, _profilePlayer, new List <IItem>());

            _startFightController = new StartFightController(_placeForUi, _startFightView, _profilePlayer);
            _startFightController.RefreshView();

            _mainMenuController?.Dispose();
            _fightWindowController?.Dispose();
            break;

        case GameState.DailyReward:
            _dailyRewardController = new DailyRewardController(_placeForUi, _dailyRewardView, _currencyView);
            _dailyRewardController.RefreshView();
            break;

        case GameState.Fight:
            _fightWindowController = new FightWindowController(_placeForUi, _fightWindowView, _profilePlayer);
            _fightWindowController.RefreshView();

            _mainMenuController?.Dispose();
            _startFightController?.Dispose();
            _gameController?.Dispose();
            break;

        default:
            DisposeAllControllers();
            break;
        }
    }