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

public class RandomHornPlayer : MonoBehaviour {

	public AudioClip[] HornSounds;
	private AudioSource _hornPlayer;
	int _maxIndex;

	void Start () 
	{
		_hornPlayer = GetComponent<AudioSource> ();
		_maxIndex = HornSounds.Length;
		PlayRandomSound ();
	}

	public void PlayRandomSound()
	{
		if (!_hornPlayer.isPlaying) 
		{
			int randomIndex = Random.Range (0, _maxIndex);
			_hornPlayer.clip = HornSounds [randomIndex];
			_hornPlayer.Play ();
		}


	}

}
