package  
{
	
	import net.flashpunk.graphics.Image;
	import net.flashpunk.FP;
	
	/**
	 * ...
	 * @author Benn
	 */
	public class GreenRock extends WindowEntity 
	{
		
		[Embed(source = "../assets/graphics/greenrock.png")] private static const GREENROCK:Class;
		
		private var GreenRockImage : Image = new Image(GREENROCK);
		
		private var DirectionX : Number = 0;
		private var DirectionY : Number = 0;
		
		private var Speed : Number = 50;
		
		private var InShieldRange : Boolean = false;
		private var InCrashRange : Boolean = false;
		private var IsDead : Boolean = false;
		
		public function GreenRock() 
		{
			graphic = GreenRockImage;
			GreenRockImage.centerOO();
		}
		
		public function SetDirection(valueX: Number, valueY : Number):void
		{
			DirectionX = valueX;
			DirectionY = valueY;
		}
		
		public function GetDirectionX():Number
		{
			return DirectionX;
		}
		
		public function GetDirectionY():Number
		{
			return DirectionY;
		}
		
		public function GetInShieldRange():Boolean
		{
			return InShieldRange;
		}
		
		public function GetInCrashRange():Boolean
		{
			return InCrashRange;
		}
		
		public function Kill():void
		{
			IsDead = true;
			FP.world.remove(this);
		}
		
		public function Die():void
		{
			IsDead = true;
			FP.world.remove(this);
		}
		
		override public function update():void 
		{
			
			if (x < WindowPositionX || x > WindowPositionX + 400 || y < WindowPositionY || y > WindowPositionY + 300)
			{
				visible = false;
			}
			else
			{
				visible = true;
			}
			
			if (InCrashRange || IsDead)
			{
				super.update();
				return;
			}
			
			x += DirectionX * Speed * FP.elapsed;
			y += DirectionY * Speed * FP.elapsed;
			
			var dist : Number = distanceToPoint(WindowPositionX + 200, WindowPositionY + 150);
			
			if (dist < 81 && dist > 60)
			{
				InShieldRange = true;
			}
			else if (dist < 60)
			{
				InCrashRange = true;
			}
			
			super.update();
		}
		
	}

}