Exemplo n.º 1
0
 public void SetUpItemUI(ItemData_SO itemData, int itemAmount)
 {
     if (itemAmount == 0)
     {
         bag.items[itemIndex].itemData = null;
         itemData = null;
     }
     if (itemData != null)
     {
         icon.sprite = itemData.itemIcon;
         if (itemData.itemType == ItemType.Weapon)
         {
             amount.text = "";
         }
         else
         {
             amount.text = itemAmount.ToString();
         }
         icon.gameObject.SetActive(true);
     }
     else
     {
         icon.gameObject.SetActive(false);
     }
 }
Exemplo n.º 2
0
 public void EquipWeapon(ItemData_SO weaponData)
 {
     if (weaponData)
     {
         attackData.ApplyWeaponData(weaponData.weaponData);
     }
 }
Exemplo n.º 3
0
    public void AddItem(ItemData_SO newItemData, int amount)
    {
        bool found = false;

        //check if already has same items in bag
        if (newItemData.stackable)
        {
            foreach (var item in items)
            {
                if (item.ItemData == newItemData)
                {
                    item.amount += amount;
                    found        = true;
                    break;
                }
            }
        }
        //create it in the next block if the item hasn't been found
        for (int i = 0; i < items.Count; i++)
        {
            if (items[i].ItemData == null && !found)
            {
                items[i].ItemData = newItemData;
                items[i].amount   = amount;
                break;
            }
        }
    }
Exemplo n.º 4
0
 public void UnEquipWeapon(ItemData_SO weaponData)
 {
     if (weaponData)
     {
         if (weaponSlot.transform.childCount != 0)
         {
             for (int i = 0; i < weaponSlot.transform.childCount; i++)
             {
                 Destroy(weaponSlot.transform.GetChild(i).gameObject);
             }
         }
         attackData.UnApplyWeaponData(weaponData.weaponData, baseAttackData);
         //TODO: change weapon animation
     }
 }
Exemplo n.º 5
0
 public void AddItem(ItemData_SO itemData, int amount)
 {
     for (int i = 0; i < items.Count; i++)
     {
         if (itemData == items[i].itemData && itemData.stackable)
         {
             items[i].amount += amount;
             break;
         }
         if (items[i].itemData == null)
         {
             items[i].itemData = itemData;
             items[i].amount   = amount;
             break;
         }
     }
 }
Exemplo n.º 6
0
    public void SetupItemUI(ItemData_SO item, int itemAmount)
    {
        if (itemAmount == 0)
        {
            Bag.items[Index].ItemData = null;
            icon.gameObject.SetActive(false);
            return;
        }

        if (item != null)
        {
            icon.sprite = item.itemIcon;
            amount.text = itemAmount.ToString();
            icon.gameObject.SetActive(true);
        }
        else
        {
            icon.gameObject.SetActive(false);
        }
    }
Exemplo n.º 7
0
 public void ChangeWeapon(ItemData_SO currentWeapon, ItemData_SO changedWeapon)
 {
     UnEquipWeapon(currentWeapon);
     EquipWeapon(changedWeapon);
 }
Exemplo n.º 8
0
 public void SetupToolTip(ItemData_SO item)
 {
     itemName.text = item.itemName;
     info.text     = item.description;
 }