Пример #1
0
 void Start()
 {
     tableItem        = new TableTileItem(null, 0);
     buildableTile    = GetComponent <BuildableTile>();
     inventoryManager = GameObject.Find("GameManager").GetComponent <InventoryManager>();
     audioManager     = GameObject.Find("GameManager").GetComponent <AudioManager>();
     InventoryRendererSlot.onInventorySlotClick += OnInventorySlotClick;
 }
Пример #2
0
    void BuyItem()
    {
        TableTileItem item = targetTable.GetItem();

        if (item != null && item.item != null && item.quantity > 0)
        {
            targetTable.RemoveItem();
            inventoryManager.AddItemToInventory(coinPrefab, item.item.saleValue);
        }
        boughtItem = true;
    }
Пример #3
0
 public void RemoveItem()
 {
     if (tableItem != null && tableItem.quantity > 0)
     {
         tableItem.quantity--;
         inventoryManager.AddItemToInventory(tableItem.item, 1);
         audioManager.PlaySound(removeSound, true);
         if (tableItem.quantity == 0)
         {
             tableItem = new TableTileItem(null, 0);
         }
         UpdateUI();
     }
 }
Пример #4
0
 void OnInventorySlotClick(Item item)
 {
     if (buildableTile.GetPlacedTile() == tablePrefab)
     {
         if (playerClose && item.saleValue > 0)
         {
             if (!tableItem.item)
             {
                 tableItem = new TableTileItem(item, 0);
             }
             if (tableItem.item && item == tableItem.item)
             {
                 tableItem.quantity++;
                 inventoryManager.RemoveItemFromInventory(item, 1);
                 audioManager.PlaySound(addSound, true);
                 if (onItemAddedToTable != null)
                 {
                     onItemAddedToTable(item);
                 }
                 UpdateUI();
             }
         }
     }
 }