using UnityEngine;
using System.Collections;

public class CabinNoiseIndicatorScript : MonoBehaviour {

	private GameObject childNoiseIndicator;
	private bool indicatorEnabled = false;

	// Use this for initialization
	void Awake () {
	
		Transform[] childObjects;
		childObjects = gameObject.GetComponentsInChildren<Transform>();
		
		foreach(Transform child in childObjects){
			
			if(child.CompareTag("CabinNoiseIndicatorChild")){
				childNoiseIndicator = child.gameObject;
			}
			
		}
		
		if(!childNoiseIndicator){
			Debug.LogError("Can't find my child noise indicator!");
		}

		childNoiseIndicator.renderer.enabled = false;
		indicatorEnabled = false;

	}
	
	// Update is called once per frame
	void Update () {
	
		/*
		if(Input.GetKeyUp(KeyCode.N)){
			if(indicatorEnabled){
				disableIndicator();
			}else{
				enableIndicator();
			}
		}
		*/

	}

	public void enableIndicator(){

		if(!childNoiseIndicator.animation.isPlaying){
			childNoiseIndicator.animation.Play();
			childNoiseIndicator.renderer.enabled = true;
			indicatorEnabled = true;
		}

	}

	public void disableIndicator(){

		if(childNoiseIndicator.animation.isPlaying){
			childNoiseIndicator.animation.Stop();
			childNoiseIndicator.renderer.enabled = false;
			indicatorEnabled = false;
		}

	}

}
