Ejemplo n.º 1
0
        public void InitTab(ShopCategory cat)
        {
            _category = cat;

            int rowsRequired = 1 + (_category.ItemsInCategory.Count / ShopController.Instance.ItemsPerRow);

            _tabRows = new Transform[rowsRequired];

            for (int i = 0; i < rowsRequired; i++)
            {
                _tabRows[i] = Instantiate(_shopRowPrefab, _content);
            }

            int currentRowIndex = 0;

            for (int index = 0; index < _category.ItemsInCategory.Count; index++)
            {
                BaseBuyable  baseBuyable  = _category.ItemsInCategory[index];
                ShopItemView shopItemView = Instantiate(_shopItemPrefab, _tabRows[currentRowIndex]);
                shopItemView.Populate(baseBuyable);

                if ((index > 0) && ((index + 1) % ShopController.Instance.ItemsPerRow == 0))
                {
                    currentRowIndex++;
                }
            }
        }
Ejemplo n.º 2
0
        private void ShopItemSelectionChanged(ShopItemView obj)
        {
            if (!_category.ItemsInCategory.Contains(obj.Buyable))
            {
                return;
            }

            if (_currentSelected)
            {
                _currentSelected.Deselect(false);
            }

            _currentSelected = obj;
        }