using UnityEngine;
using System.Collections;

public class ArmeBarricade : MonoBehaviour {
	public GameObject emplacement;
	private int nbvies = 5;

	void OnCollisionEnter(Collision collision) {
		if (collision.gameObject.name == "Ennemi(Clone)" || collision.gameObject.name == "Ennemi1(Clone)") {
			nbvies--;
			Destroy(collision.gameObject);
			Game.instance.compteurpoints++;
			Game.instance.nbEnnemiTue++;
			Game.instance.score++;
			if (nbvies<=0){
				GameObject place = Instantiate(emplacement,transform.position,Quaternion.identity) as GameObject ;
				if (Game.instance.niveau==1){
					place.transform.parent = Game.instance.placementTourelle1.transform ;
				}
				if (Game.instance.niveau==2){
					place.transform.parent = Game.instance.placementTourelle2.transform ;
				}
				place.transform.rotation=transform.rotation;
				Destroy (gameObject);
			}
		}
	}
}
