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

public class EmittingSound : ReactOnWaveHit
{

	public AudioClip soundBounce;

	private AudioSource source;

//	private float maxSeconds = 3;

	void Start() {
		gameObject.AddComponent<AudioSource>();
		source = GetComponent<AudioSource>();
		source.clip = soundBounce;
	}

	void Awake() {
	}

	public override void hitByWave(Wave wave, float strength)
	{
		if (!source.isPlaying) {
			source.volume = Random.Range(0.5f, 1f);
			source.Play();
		}
		
		Wave.createWave(wave.transform.position, wave.transform.position - transform.position, 270, 10, 20, false, false);
	}

	void Update() {
//		if (source.isPlaying && source.time > maxSeconds) {
//			source.Stop();
//		}
	}
}
