示例#1
0
    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);
        }
    }
示例#2
0
    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);
        }
    }