示例#1
0
        private void Init()
        {
            // DataEntities
            _heroComponent = FindObjectOfType <HeroComponent>();
            var bagEntities   = ResourcesExt.LoadDataEntities(NameBag);
            var dummyEntities = ResourcesExt.LoadDataEntities(NameDummy);

            // Inventories
            _dummy = new InventoryOpenCloseObject(_prefabDummyInventory, dummyEntities, NameDummy);
            _bag   = new InventoryOpenCloseObject(_prefabBagInventory, bagEntities, NameBag);

            _inventoryDataBindHotBar = _containerDi.InventoryBindingFactory.Create(_inventoryComponentHotBar)
                                       .Bind(_inventoryComponentHotBar);

            // Listeners
            _buffDebafListener = new BuffDebuffListener(_heroComponent, _dummy);
            _hotBarListener    = new HotBarListener(_inventoryDataBindHotBar, _bag);
            _changeAmountEntityInInventoryListener = new ChangeAmountEntityInInventoryListener(_bag);
        }
        public InventoryOpenCloseObject(GameObject prefabWithInventory,
                                        IEnumerable <DataEntity> dataEntitiesForLoad = null,
                                        string nameInventory = NameInventoryDefault)
        {
            _prefabWithInventory = prefabWithInventory;
            _nameInventory       = nameInventory;
            var inventoryComponent = InventoryComponent.GetInventoryComponent(prefabWithInventory.transform);

            CheckInventoryOnScene(inventoryComponent);

            _inventoryBinding = InventoryBindingFactory.Create(inventoryComponent, dataEntitiesForLoad);
            _inventoryBinding.ChangeState.AddListener(state =>
            {
                if (state == State.UnBind)
                {
                    ProcessClose();
                }
            });
        }