예제 #1
0
    public void AddItem(BlockTypes blockType)
    {
        for (int i = 0; i < ItemCount; i++)
        {
            InventoryItem item = Items[i];
            if (item == null)
            {
                continue;
            }

            if (item.BlockType == blockType && item.CanRaiseCount())
            {
                item.RaiseCount();
                ItemsUpdated(this, new InventoryEventArgs());
                return;
            }
        }

        for (int i = 0; i < ItemCount; i++)
        {
            InventoryItem item = Items[i];
            if (item == null)
            {
                Items[i] = new InventoryItem(blockType);
                ItemsUpdated(this, new InventoryEventArgs());
                return;
            }
        }

        return;
    }