コード例 #1
0
        private IAbilitiesController ConfigureAbilityController(
            Transform placeForUi,
            IAbilityActivator abilityActivator, ProfilePlayer profilePlayer)
        {
            var abilityItemsConfigCollection
                = ContentDataSourceLoader.LoadAbilityItemConfigs(new ResourcePath
            {
                PathResource = "DataSource/Ability/AbilityItemConfigDataSource"
            });
            var abilityRepository
                = new AbilityRepository(abilityItemsConfigCollection);
            var abilityCollectionViewPath
                = new ResourcePath {
                PathResource = $"Prefabs/{nameof(AbilityCollectionView)}"
                };
            var abilityCollectionView
                = ResourceLoader.LoadAndInstantiateObject <AbilityCollectionView>(abilityCollectionViewPath, placeForUi,
                                                                                  false);

            AddGameObjects(abilityCollectionView.gameObject);

            var abilitiesController = new AbilitiesController(abilityRepository, profilePlayer.InventoryModel,
                                                              abilityCollectionView, abilityActivator);

            AddController(abilitiesController);

            return(abilitiesController);
        }
コード例 #2
0
ファイル: GameController.cs プロジェクト: Injection735/racing
        private IAbilitiesController ConfigureAbilityController(Transform placeForUi, IAbilityActivator abilityActivator, IReadOnlyList <IItem> items)
        {
            var abilityItemsConfigCollection = ContentDataSourceLoader.LoadAbilityItemConfigs(new ResourcePath {
                PathResource = "DataSource/Abilities/AbilityItemConfigDataSource"
            });
            var abilityRepository         = new AbilityRepository(abilityItemsConfigCollection);
            var abilityCollectionViewPath = new ResourcePath {
                PathResource = $"Prefabs/{nameof(AbilityCollectionView)}"
            };
            var abilityCollectionView = ResourceLoader.LoadAndInstantiateObject <AbilityCollectionView>(abilityCollectionViewPath, placeForUi, false);

            AddGameObjects(abilityCollectionView.gameObject);

            // загрузить в модель экипированные предметы можно любым способом
            var inventoryModel = new InventoryModel();

            inventoryModel.EquipItems(items);

            var abilitiesController = new AbilitiesController(abilityRepository, inventoryModel, abilityCollectionView, abilityActivator);

            AddController(abilitiesController);

            return(abilitiesController);
        }
コード例 #3
0
        private BaseController ConfigureAbilityController(Transform placeForUi, IAbilityActivator abilityActivator)
        {
            var abilityItemsConfigCollection
                = ContentDataSourceLoader.LoadAbilityItemConfigs(new ResourcePath {
                PathResource = "DataSource/Ability/AbilityItemConfigDataSource"
            });

            var abilityRepository
                = new AbilityRepository(abilityItemsConfigCollection);

            var abilityCollectionViewPath
                = new ResourcePath {
                PathResource = $"Prefabs/{nameof(AbilityCollectionView)}"
                };
            var abilityCollectionView =
                ResourceLoader.LoadAndInstantiateObject <AbilityCollectionView>(abilityCollectionViewPath, placeForUi, false);

            AddGameObjects(abilityCollectionView.gameObject);

            var abilityItemsRepository
                = new ItemsRepository(abilityItemsConfigCollection.Select(value => value.ItemConfig).ToList());

            var inventoryModel = new InventoryModel();

            foreach (var item in abilityItemsRepository.Collection.Values)
            {
                inventoryModel.EquipItem(item);
            }

            var abilitiesController = new AbilitiesController(abilityRepository, inventoryModel, abilityCollectionView,
                                                              abilityActivator);

            AddController(abilitiesController);

            return(abilitiesController);
        }