using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class HealthPickup : MonoBehaviour
{
    // Audio
    public AudioSource Audio;
    public AudioClip HealthSound;

    public Transform meshes;

    bool isPickedUp = false;

    private void OnTriggerEnter(Collider c)
    {
        // checks for player and is pickable 
        if (c.tag == "Player" && !isPickedUp)
        {
            Health playerHealth = c.GetComponent<Health>();

            if (playerHealth.health >= playerHealth.maxHealth) return;

            Audio.PlayOneShot(HealthSound);
            playerHealth.health = playerHealth.maxHealth;
            isPickedUp = true;
            meshes.gameObject.SetActive(false);
        }
    }
}