Inventory.updateItemList C# (CSharp) Method

updateItemList() public method

public updateItemList ( ) : void
return void
    public void updateItemList()
    {
        ItemsInInventory.Clear();
        for (int i = 0; i < SlotContainer.transform.childCount; i++)
        {
            Transform trans = SlotContainer.transform.GetChild(i);
            if (trans.childCount != 0)
            {
                ItemsInInventory.Add(trans.GetChild(0).GetComponent<ItemOnObject>().item);
            }
        }
    }

Usage Example

コード例 #1
0
ファイル: PickUpItem.cs プロジェクト: cating341/Goosebumps
 // Update is called once per frame
 void Update()
 {
     if (_inventory != null && UserControl.PickupItem)
     {
         float distance = Vector2.Distance(new Vector2(this.gameObject.transform.position.x, this.gameObject.transform.position.y), new Vector2(_player.transform.position.x, _player.transform.position.y));
         print("distance: " + distance);
         if (distance <= 1.3)
         {
             sceneManager.GetComponent <MySceneManager>().removeFromGearList(this.gameObject);
             bool check = _inventory.checkIfItemAllreadyExist(item.itemID, item.itemValue);
             if (check)
             {
                 Destroy(this.gameObject);
             }
             else if (_inventory.ItemsInInventory.Count < (_inventory.width * _inventory.height))
             {
                 _inventory.addItemToInventory(item.itemID, item.itemValue);
                 _inventory.updateItemList();
                 _inventory.stackableSettings();
                 Destroy(this.gameObject);
             }
         }
     }
     if (_inventory != null && UserControl.GetGearsBack)
     {
         addItemToInv(item.itemID, item.itemValue);
     }
 }
All Usage Examples Of Inventory::updateItemList