package Game.Objects
{
	import Engine.GameSprite;
	import flash.geom.Point;
	import Game.Effects.Explosion;
	import Game.LibGraphics;
	import Game.Objects.Bullets.FireBullet;
	import Game.Objects.Bullets.RocketBullet;
	import Game.Objects.Bullets.SimpleBullet;
	
	/**
	 * ...
	 * @author KEFIR
	 */
	public class RocketEnemy extends GameSprite
	{
		private var _speed:Number = 2;
		private var _shoted:Boolean = false;
		
		private var _health:int = 30;
		
		override public function Move():void
		{
			x = x - _speed;
			
			_speed += 0.1;
			
			if(!_shoted){
				if (x <= 550) {
					
					var shot:RocketBullet = new RocketBullet();
					shot.x = x;
					shot.y = y;
					Group.AddSprite(shot);
					
					_shoted = true;
				}
			}else{
				y = y - 2;
			}
			
			if (x < -100) {
				Delete = true;
			}
		}
		
		override public function Collision(Intersects:GameSprite):void
		{
			if (Intersects is SimpleBullet) {
				Intersects.Delete = true;
				
				_health -= 3;
			}
			
			if (Intersects is FireBullet) {
				Intersects.Delete = true;
				
				_health -= 5;
			}
			
			if (_health <= 0) {
				Delete = true;
				
				Group.AddSprite(new Explosion(x, y));
			}
		}
		
		public function RocketEnemy()
		{
			super(new LibGraphics.RocketLauncher(), new Point(65, 95));
			CollisionEnabled = true;
		}
		
	}

}