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

public class VoidTrigger : MonoBehaviour
{
    public Transform playerTransform;
    public LevelManager levelManager;

    public float deathHeight;
    public AudioSource voidDeathAudioSource;

    bool dead;

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKeyDown(KeyCode.F6)) // if quickload key pressed....
        {
            dead = false;
            voidDeathAudioSource.Stop();
            levelManager.fellIntoVoid = false;
        }


        if (!dead && playerTransform.position.y < deathHeight && !levelManager.freezeGame && !voidDeathAudioSource.isPlaying)
        {
            voidDeathAudioSource.Play();

            dead = true;
        }

        if (voidDeathAudioSource.time >= 3.5f)
        {
            voidDeathAudioSource.Stop();
        }

        if (dead && !voidDeathAudioSource.isPlaying)
        {
            levelManager.fellIntoVoid = true;

            dead = false; // reset
        }
 




    }
}
