using UnityEngine;
using System.Collections;

public class BulletBehaviour : MonoBehaviour {

	private const float SPEED = 2.5f;
	
	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		float delta = Time.deltaTime * SPEED;
		Vector3 vec = new Vector3 (-delta, 0, 0);
		vec = Vector3.ClampMagnitude(vec, delta);
		//vec = vec * Referee.LevelSpeed;
		this.transform.Translate(vec);
	}
	
	void OnCollisionEnter2D(Collision2D coll){
		StartCoroutine(SplatAnimation());
	}
	
	void OnCollisionStay2D(Collision2D coll){
		StartCoroutine(SplatAnimation());
	}
	
	IEnumerator SplatAnimation(){
		Animator anim = GetComponent<Animator>();
		anim.CrossFade("Splat", 0f);
		yield return new WaitForSeconds(0.2f);
		Destroy(this.gameObject);
	}
}
