public void AddArmor() { if (playerInventory == null) { playerInventory = FindObjectOfType <PlayerInventory>(); } if (playerLife == null) { playerLife = FindObjectOfType <PlayerLife>(); } if (playerInventory.scrap >= addArmorCost) { playerLife.IncreaseArmor(addArmorAmount); playerInventory.AddScrap(-addArmorCost); } }
void OnTriggerEnter2D(Collider2D col) { if (col.tag == "Player") { switch (itemsData.type) { case ItemsData.itemType.FOOD: playerInventory.AddFood(itemsData.amount); break; default: playerInventory.AddScrap(itemsData.amount); break; } Destroy(gameObject); } }