﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Arugula.Audio;

namespace Arugula.Games
{
    public class PhonicDestructible : MonoBehaviour
    {
        [PhonicSound]
        public string destroyedSound;

        [PhonicSound]
        public string damagedSound;

        [PhonicSound]
        public string healedSound;

        public Phonic.Options options;

        // Start is called before the first frame update
        void Start()
        {
            var d = GetComponent<DestructibleObject>();
            d.OnDestroyed += (x, y) => { options.position = transform.position; Phonic.Play(destroyedSound, options); };
            d.OnDamaged += (x, y) => { options.position = transform.position; Phonic.Play(damagedSound, options); };
            d.OnHealed += (x, y) => { options.position = transform.position; Phonic.Play(healedSound, options); };
        }
    }
}