Пример #1
0
    private void ProcessCardData()
    {
        _title.BbcodeText       = _cardData?.Name;
        _description.BbcodeText = _cardData?.Description;

        if (_cardData == null)
        {
            _cardImage.Texture = null;
        }
        else
        {
            _cardImage.Texture = CardManagerHelper.GetCardResource(_cardData.Image);

            switch (_cardData.Type)
            {
            case "weapon":
            case "item":
                _okButton.Hide();
                _takeButton.Show();
                _discardButton.Show();
                break;

            case "event":
                _okButton.Show();
                _takeButton.Hide();
                _discardButton.Hide();
                break;
            }
        }
    }
Пример #2
0
    public void DrawItems()
    {
        ClearGridChildren();

        var weapon = _items.FirstOrDefault(x => x.Type == CardManagerHelper.CardTypes.Weapon);

        if (weapon != null)
        {
            var cellTexture = CardManagerHelper.GetCardResource(weapon.Image);

            _weaponCell.SetCardData(weapon);
            _weaponCell.SetCellIndex(-1);
            _weaponCell.SetCellSprite(cellTexture);
        }

        var cellIndex = 0;

        foreach (var item in _items.Where(x => x.Type == CardManagerHelper.CardTypes.Item))
        {
            var itemCellScene = ResourceLoader.Load <PackedScene>("res://Assets/UI/Inventory/ItemCell.tscn");

            if (itemCellScene != null)
            {
                var itemCellInstance = (ItemCell)itemCellScene.Instance();

                _gridContainer.AddChild(itemCellInstance);

                var cellTexture = CardManagerHelper.GetCardResource(item.Image);

                itemCellInstance.SetCardData(item);
                itemCellInstance.SetCellIndex(cellIndex);
                itemCellInstance.SetCellSprite(cellTexture);

                itemCellInstance.Connect("ItemCellClicked", this, "_On_ItemCellClicked");

                cellIndex++;
            }
        }
    }