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); }
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); }
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); }