using UnityEngine;
using System.Collections;

public class Deadline : MonoBehaviour {
	
	public AudioClip m_Audio;
	
	// Use this for initialization
	void Start () 
	{
		AudioSource sound = gameObject.AddComponent<AudioSource>();
		sound.clip = m_Audio;
		sound.Play();
	}
	
	// Update is called once per frame
	void Update () 
	{
		Vector3 pos = transform.position;
		pos.x += 100*Time.deltaTime;
		transform.position = pos;
	}
	
	void OnTriggerEnter(Collider coll)
	{
		GameObject go = coll.gameObject;
		if(go.tag=="Unit")
		{
			go.GetComponent<Unit>().m_StressMeter = 100;	
		}
		if(go.tag=="Hero")
		{
			SafeZoneBehaviour safeZone = GameObject.FindGameObjectWithTag("SafeZone").GetComponent<SafeZoneBehaviour>();
			if(!safeZone.m_HeroInSafeZone || !safeZone.IsHeroDone())
				go.GetComponent<Hero>().DestroyMe();	
		}
	}
}
