var rotate : boolean = true;
function Awake() {
	animation["Walk"].speed = 1.5;
	if(animation["Sleep"])
		animation["Sleep"].speed = 0.5;
	animation["Fire"].speed = 0.75;
	animation["Hit"].speed = 0.75;
}

function Update () {
	var policeAI = GetComponent(PoliceAI);
	if(!policeAI.dead && !policeAI.sleep && !policeAI.hit){
		transform.rotation.x = 0;
		if(policeAI.isFiring() == true) {
			animation.Play("Fire");
		} else {
			animation.Stop("Fire");
		}
		if(policeAI.isMoving() == true){
			animation.Play("Walk");
		} else if(policeAI.isFiring() == false){
			animation.Play("Ready1");
		} 
	} else if(policeAI.sleep){
		animation.CrossFade("Sleep");
		if(rotate)
			transform.Rotate(270,0,0);
			rotate = false;
	} else if(policeAI.hit){
		animation.Play("Hit");
	} else {
		animation.Stop();
	}
}

@script RequireComponent(PoliceAI)
@script AddComponentMenu("Police/Police Animation")