Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (Managers.player.IsDead())
        {
            return;
        }
        if (useBlock)
        {
            return;
        }

        int KeyDownIndex = GetKeyDownIndex();

        if (KeyDownIndex != -1)
        {
            if (!Managers.player.moveBlock)
            {
                if (listGameItem[KeyDownIndex] != null)
                {
                    Managers.inventory.UseItemFromInventory(listGameItem[KeyDownIndex]);
                }
            }
        }



        for (int i = 0; i < transform.childCount; i++)
        {
            QuickBarCell qBcell     = transform.GetChild(i).GetChild(0).GetComponent <QuickBarCell>();
            Image        _cellImage = transform.GetChild(i).GetChild(0).GetComponent <Image>();

            GameItem _item = listGameItem[i];
            if (_item != null)
            {
                _cellImage.sprite = _item._itemSprite;
                _cellImage.color  = new Color(255, 255, 255, 255);

                if (_item._count > 0)
                {
                    qBcell.transform.GetChild(0).GetComponent <Text>().text = _item._count.ToString();
                }
                else
                {
                    qBcell.transform.GetChild(0).GetComponent <Text>().text = "";
                }
            }
            else
            {
                _cellImage.sprite = qBcell.emptyButtonSprite;
                _cellImage.color  = qBcell.emptyButtonColor;
                qBcell.transform.GetChild(0).GetComponent <Text>().text = "";
            }
        }
    }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        listGameItem = new List <GameItem>();
        useBlock     = false;

        for (int i = 0; i < transform.childCount; i++)
        {
            QuickBarCell qbCell = transform.GetChild(i).GetChild(0).GetComponent <QuickBarCell>();
            if (qbCell != null)
            {
                qbCell.SetIndex(i);
                GameItem _item = null;
                listGameItem.Add(_item);
            }
        }

        Debug.Log("list item count = " + listGameItem.Count);
    }
Esempio n. 3
0
    public void OnDrop(PointerEventData eventData)
    {
        Debug.Log("OnDrop");
        Debug.Log("OnDrop name =" + eventData.pointerDrag.name);

        //Добавляем предмет в QuickBar из инвентаря
        InventButton invButton = eventData.pointerDrag.GetComponent <InventButton>();

        if (invButton != null)
        {
            if (invButton._gameItemRef != null)
            {
                quickBar.AddGameItem(invButton._gameItemRef, index);
            }
        }

        //Перемещение из ячейки квик бара
        QuickBarCell qBcell = eventData.pointerDrag.GetComponent <QuickBarCell>();

        if (qBcell != null)
        {
            quickBar.ReplaceGameItem(index, qBcell.GetIndex());
        }
    }