예제 #1
0
        private ShedController ConfigureShedController(Transform placeForUi,
                                                       ProfilePlayer profilePlayer, IInventoryModel inventoryModel)
        {
            var upgradeItemsConfigCollection
                = ContentDataSourceLoader
                  .LoadUpgradeItemConfigs(new ResourcePath {
                PathResource = "DataSource/Upgrade/UpgradeItemConfigDataSource"
            });
            var upgradeItemsRepository
                = new UpgradeHandlersRepository(upgradeItemsConfigCollection);

            var itemsRepository
                = new ItemsRepository(upgradeItemsConfigCollection
                                      .Select(value => value.ItemConfig).ToList());

            //var inventoryModel
            //    = new InventoryModel();

            var inventoryView = _view.InventoryView;

            AddGameObjects(inventoryView.gameObject);
            var inventoryController
                = new InventoryController(itemsRepository, inventoryModel, inventoryView);

            AddController(inventoryController);

            var shedController
                = new ShedController(upgradeItemsRepository, inventoryController, profilePlayer.CurrentCar);

            AddController(shedController);

            return(shedController);
        }
예제 #2
0
        private ShedController ConfigureShedController(Transform placeForUi, ProfilePlayer profilePlayer)
        {
            var upgradeItemsConfigCollection = ContentDataSourceLoader.LoadUpgradeItemConfigs(new ResourcePath {
                PathResource = "DataSource/Upgrade/UpgradeItemConfigDataSource"
            });
            var upgradeItemsRepository = new UpgradeHandlersRepository(upgradeItemsConfigCollection);

            var itemsRepository   = new ItemsRepository(upgradeItemsConfigCollection.Select(value => value.itemConfig).ToList());
            var inventoryModel    = new InventoryModel();
            var inventoryViewPath = new ResourcePath {
                PathResource = $"Prefabs/{nameof(InventoryView)}"
            };

            var inventoryView = ResourceLoader.LoadAndInstantiateObject <InventoryView>(inventoryViewPath, placeForUi, false);

            AddGameObjects(inventoryView.gameObject);

            var inventoryController = new InventoryController(itemsRepository, inventoryModel, inventoryView);

            AddController(inventoryController);

            var shedController = new ShedController(upgradeItemsRepository, inventoryController, profilePlayer.CurrentCar);

            AddController(shedController);

            return(shedController);
        }
예제 #3
0
        public MainMenuController(Transform placeForUi, ProfilePlayer profilePlayer,
                                  UnityAdsTools unityAdsTools)
        {
            _profilePlayer = profilePlayer;
            _unityAdsTools = unityAdsTools;
            _view          = LoadView(placeForUi);
            _view.Init(StartGame, EnterGarage);

            _mainMenuTrailController = new MainMenuTrailController();
            AddController(_mainMenuTrailController);

            _shedController = ConfigureShedController(placeForUi, profilePlayer);
            AddController(_shedController);
        }
예제 #4
0
        public MainMenuController(Transform placeForUi, ProfilePlayer profilePlayer)
        {
            _profilePlayer = profilePlayer;
            _view          = ResourceLoader.LoadAndInstantiateObject <MainMenuView>(new ResourcePath {
                PathResource = "Prefabs/MainMenu"
            }, placeForUi, false);
            AddGameObjects(_view.gameObject);
            _view.Init(StartGame, DailyRewardGame);

            // можно внедрить как зависимость для другого контроллера
            var cursorTrailController = ConfigureCursorTrail();

            _shedController = ConfigureShedController(placeForUi, profilePlayer);

            _shedController.Enter();
        }
예제 #5
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;
        }
    }