package  
{
	import net.flashpunk.Entity;
	import net.flashpunk.graphics.Image;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author Benn
	 */
	public class Laser extends Entity 
	{
		
		[Embed(source = '../assets/graphics/laserleft.png')] private static const LASERLEFT_GRAPHIC:Class;
		[Embed(source = '../assets/graphics/laserright.png')] private static const LASERRIGHT_GRAPHIC:Class;
		[Embed(source ='../assets/graphics/laserdown.png')] private static const LASERDOWN_GRAPHIC:Class;
		
		private var LaserImage:Image;
		
		private var Beam:LaserBeam = new LaserBeam;
		
		private var LaserType:int = 0;
		
		public function Laser(Type:int) 
		{
			
			Beam.BeamDirection = Type;
			LaserType = Type;
			
			if (Type == 0)
			{
				LaserImage = new Image(LASERLEFT_GRAPHIC);
			}
			else if (Type == 1)
			{
				LaserImage = new Image(LASERRIGHT_GRAPHIC);
			}
			else
			{
				LaserImage = new Image(LASERDOWN_GRAPHIC);
			}
			
			graphic = LaserImage;
		}
		
		public function ActivateBeam():void
		{
			
			if (LaserType == 0)
			{
			
				var PosX:int = 640 - (x+26);
				
				Beam.BeamImage.scaleX = 320 - (PosX / 2);
				
				Beam.setHitbox(Beam.BeamImage.scaledWidth, 2);
				
				Beam.x = 0;
				Beam.y = y + 15;
			
			}
			else if (LaserType == 1)
			{
				
				Beam.BeamImage.scaleX = 320;
				
				Beam.x = x + 6;
				Beam.y = y + 15;
			}
			else
			{
				Beam.x = x + 15;
				Beam.y = y + 6;
				
				Beam.BeamImage.scaleY = 320;
				
			}
			
			FP.world.add(Beam);
			
		}
		
		public function DeactivateBeam():void
		{
			Beam.FlagDelete = true;
			FP.world.remove(Beam);
		}
		
	}

}