コード例 #1
0
ファイル: Item_Fetcher.cs プロジェクト: SirRolf/Cube
 // THIS SHOULD BE DIFFRENT, LOAD WHENEVER SOMTHING HAPPENS BUT I DON'T KNOW WHERE
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         _backpackItem = GetComponentInChildren <Inventory>().backpackItem;
         _backpackItem.Load();
     }
 }
コード例 #2
0
ファイル: Item_Fetcher.cs プロジェクト: SirRolf/Cube
 private void OnTriggerStay2D(Collider2D col)
 {
     _backpackItem = GetComponentInChildren <Inventory>().backpackItem;
     if (Input.GetAxisRaw("PickUp") != 0)
     {
         var item = col.GetComponent <GroundItem>();
         if (item == true)
         {
             _backpackItem.AddItem(new Item(item.item), 1);
             Destroy(col.gameObject);
             _backpackItem.Save();
         }
     }
 }
コード例 #3
0
    public void Equip(GameObject containerSlot, Container_Object container)
    {
        GameObject _panelUIElement = Instantiate(panelUIElement, transform.position, Quaternion.identity);

        _panelUIElement.transform.SetParent(inventoryPanel.transform);
        _panelUIElement.GetComponent <RectTransform>().sizeDelta        = new Vector2(container.xSize * 100 + 20, container.ySize * 100 + 20);
        _panelUIElement.GetComponent <RectTransform>().anchoredPosition = new Vector2(300, -50);
        _panelUIElement.name = container.type.ToString();
        int size = container.xSize * container.ySize;

        for (int i = 0; i < size; i++)
        {
            GameObject _slotUIElement = Instantiate(slotUIElement, transform.position, Quaternion.identity);
            _slotUIElement.transform.SetParent(_panelUIElement.transform);
            _slotUIElement.name = slotUIElement.name;
        }
        containerSlot.GetComponent <Image>().sprite = container.slotSprite;
        backpackItemPanel = _panelUIElement;
    }