コード例 #1
0
    private void OnConsume()
    {
        var item = EquippedItem as ConsumableItem;

        if (item.Consumptions > 0)
        {
            if (consumeSFX)
            {
                AudioSource.PlayClipAtPoint(consumeSFX, transform.position);
            }

            item.Consume();
            PlayerStatistics playerStatistics = GetComponent <PlayerStatistics>();
            playerStatistics.ChangePlayerHealth(item.Properties.HealthOnConsume);
            playerStatistics.ChangePlayerHunger(item.Properties.HungerOnConsume);
            playerStatistics.ChangePlayerRadiation(item.Properties.RadiationOnConsume);

            if (item.Consumptions == 0)
            {
                RemoveEquipment();
                ItemCollector itemCollector = GetComponent <ItemCollector>();
                itemCollector.RemoveFromInventory(item);
            }
        }
    }