﻿using UnityEngine;
using System.Collections;

public class RandomThunder : MonoBehaviour {
	
	private float maxSpawnTime = 16.0f;
	
	private float minSpawnTime = 8.0f;
	
	
	
	
	void Start()
	{
		Invoke("ThunderSound", Random.Range(minSpawnTime, maxSpawnTime));
	}
	
	void ThunderSound()
	{
		audio.pitch = Random.Range(0.90f, 1.0f);
		if (audio.isPlaying)
		{
			Invoke("ThunderSound", Random.Range(minSpawnTime, maxSpawnTime));
		}
		else
		{
			audio.Play();
			Invoke("ThunderSound", Random.Range(minSpawnTime, maxSpawnTime));
		}
	}
}