using UnityEngine;
using System.Collections;

public class MoveLava : MonoBehaviour {
	public Transform fire;
	public float speed = 4f;
	public float die =30f;
	// Use this for initialization
	void Start () {
		Destroy(gameObject, die);
	}
	
	// Update is called once per frame
	void Update () {
		transform.Translate(new Vector3(Time.deltaTime * speed,0,0));
//		rigidbody.AddForce(new Vector3(0,0,Time.deltaTime * 40f));
	}
	
	void OnCollisionEnter (Collision col){
	
		if (col.gameObject.tag == "Burn" || col.gameObject.tag == "Cell" ) {
			AudioManager.instance.Play (Sounds.Blast, col.gameObject.transform);
			
			Vector3 p = (col.gameObject.transform.position + transform.position) / 2f;
			Instantiate (fire,p + new Vector3(0,0,0),Quaternion.identity);
			Destroy (col.gameObject);
			Destroy (gameObject);
		} else
		if (col.gameObject.tag == "Npc") {
			AudioManager.instance.Play (Sounds.Die1, col.gameObject.transform);
			HudController.instance.DecCitzen();
			Vector3 p = (col.gameObject.transform.position + transform.position) / 2f;
			Instantiate (fire,p + new Vector3(0,0,0),Quaternion.identity);
			Destroy (col.gameObject);
			Destroy (gameObject);
		}
	}
}
