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

namespace Prisma
{
    public class CameraSc : MonoBehaviour
    {

        [SerializeField]
        private AudioClip[] clips;
        private AudioSource source;
        private bool alarm;
        [SerializeField]
        private GameObject player;

        void Start()
        {
            alarm = false;
            source = GetComponent<AudioSource>();
        }

        public void Alert()
        {
            StartCoroutine(AlertTime());
        }

        private IEnumerator AlertTime()
        {
            alarm = true;
            source.Stop();
            source.clip = clips[2];
            source.volume = 1.0f;
            source.pitch = 1.0f;
            source.Play();
            yield return new WaitForSeconds(0.5f);
            source.Stop();
            source.clip = clips[1];
            source.volume = 0.5f;
            source.pitch = 1.0f;
            source.loop = true;
            source.Play();
            yield return new WaitForSeconds(4.5f);
            source.Stop();
            source.clip = clips[0];
            source.loop = false;
            source.volume = 0.25f;
            source.pitch = 0.5f;
            source.Play();
            alarm = false;
        }

        public bool RAlarm()
        {
            return alarm;
        }

        public void Sound()
        {
            source.Play();
        }
    }
}