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

public class SoundBlast : MonoBehaviour {
    public enum Type { Major, Minor, Stone, Medusa, Menu }
    [SerializeField]
    private float strength = 30;
    [SerializeField]
    Type type = Type.Minor;

    private bool medusaHit = false, playerHit = false;

    private void Update()
    {
        if (type == Type.Medusa)
        {
            if (!playerHit && Vector3.Distance(transform.position, Player.instance.transform.position) < transform.localScale.x / 2)
            {
                Player.instance.TakeDamage(25);
                playerHit = true;
            }
        }
        else if (type != Type.Menu)
        {
            if (!medusaHit)
            {
                foreach (var g in Gorgon.all)
                {
                    if (Vector3.Distance(transform.position, g.transform.position) < transform.localScale.x / 2)
                    {
                        g.OnInterceptedSound(strength);
                        medusaHit = true;
                        break;
                    }
                }
            }
        }
    }

}
