コード例 #1
0
        /// <summary>
        /// Put an object in an inventory slot
        /// </summary>
        public void AddObject(PlayerObjectScript obj, int slotIndex)
        {
            // can't add object if inventory is full

            if (slotIndex != -1)
            {
                inventory[slotIndex].SetItem(obj);
            }
        }
コード例 #2
0
        public void SetItem(PlayerObjectScript obj)
        {
            item = obj;
            stack++;

            if (obj == null)
            {
                stack = 0;
            }
        }
コード例 #3
0
        public void Use()
        {
            if (stack > 0)
            {
                stack--;
            }

            if (stack == 0)
            {
                item = null;
            }
        }
コード例 #4
0
 public PlayerInventorySlot()
 {
     stack = 0;
     item  = null;
 }
コード例 #5
0
 /// <summary>
 /// Set image associated to the object in the UI slot item
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="index"></param>
 public void SetItemUISlot(PlayerObjectScript obj, int index)
 {
     inventorySlotUI[index].transform.GetChild(1).GetComponent <Image>().sprite = obj != null?obj.GetSprite() : defaultInvImage;
 }