var bulletSpeed: int;

var explosion: Transform;
var target:Transform;
var homingActive:boolean=true;
var AimingActive:boolean=true;
var projectType:int=0;
var aimingTime:float=2.0;
var destroyTime:float=1.5;

public var rotationOffset:float=0;

private var aimingTimer:float=0.0;


function Start(){

       target= GameObject.Find("player").transform;
	   
	   
	  
}

function Update () {

   if((aimingTimer <= aimingTime )&&(AimingActive==true)){
   
   transform.LookAt(target);

   }

switch( projectType){


      case 0: 
	  transform.Translate(Vector3.forward*  bulletSpeed * Time.deltaTime);
	  break;
	  
      case 1:
	  transform.Translate(Vector3.left*  bulletSpeed * Time.deltaTime);
	 break;

     case 2:
	  transform.Translate(Vector3.up*  bulletSpeed * Time.deltaTime);
	 break; 
	
	case 3:
	  transform.Translate(Vector3.right*  bulletSpeed * Time.deltaTime);
	 break; 
	
	case 4:
	  transform.Translate(Vector3.down*  bulletSpeed * Time.deltaTime);
	 break;

    
	}
	Destroy(gameObject,destroyTime);



   aimingTimer += Time.deltaTime;
}



function OnTriggerEnter(  otherObject: Collider){

	if(otherObject.gameObject.tag == "Player"){

	
	
	var tempExplosion: Transform;
	
	tempExplosion = Instantiate(explosion, transform.position, transform.rotation);
	
	GameController.playerLives --;
	Destroy(gameObject);
	
	}else if((otherObject.gameObject.tag == "BG") ||  (otherObject.gameObject.tag == "option")                           ){

    Destroy(gameObject);
	}

}