package game.GameMain.Mobs
{
	import flash.geom.Point;
	import flinjin.events.FlinjinSpriteEvent;
	import flinjin.graphics.Layer;
	import flinjin.graphics.Sprite;
	import flinjin.sound.FlinjinSound;
	import flinjin.sound.FlinjinSoundCollection;
	import flinjin.types.BoundingRect;
	import game.GameMain.TileLevel;
	
	/**
	 * ...
	 * @author Michael Miriti
	 */
	public class MantisMob extends SceletonMob
	{
		[Embed(source="../../../assets/mantis/bogomol.PNG")]
		private static var _bmpBody:Class;
		
		private var _claw1:MantisClaw;
		private var _claw2:MantisClaw;
		private var _body:Sprite;
		
		private var _snd:FlinjinSound;
		
		public function MantisMob()
		{
			super(200, 200);
			
			setCenter(140, 195);
			_body = new Sprite(new _bmpBody());
			addSprite(_body, 100, 100);
			
			_claw1 = new MantisClaw();
			_claw2 = new MantisClaw();
			
			_claw1.angle = -Math.PI / 8;
			_claw2.angle = Math.PI / 8;
			
			addSprite(_claw1, 130, 138);
			addSprite(_claw2, 130, 138);
			
			setBoundingShape(new BoundingRect(this, 40, 20, new Point( -40, -40)));
			_snd = FlinjinSoundCollection.getSound("mantis");
			
			addEventListener(FlinjinSpriteEvent.ADDED_TO_LAYER, onAdded);
		}
		
		override public function Move():void 
		{
			super.Move();
		}
		
		override public function Dispose():void 
		{
			_snd.stop();
			super.Dispose();
		}
		
		private function onAdded(e:FlinjinSpriteEvent):void 
		{
			_snd.loop = true;
			_snd.play();
		}
	
	}

}
import flash.display.Bitmap;
import flash.geom.Point;
import flinjin.graphics.Sprite;

class MantisClaw extends Sprite
{
	[Embed(source="../../../assets/mantis/bogomol_lapa.png")]
	private static var _bmpClaw:Class;
	
	public var attack:Boolean;
	
	override public function Move():void 
	{
		super.Move();
		
		if (attack) {
			if (angle > -Math.PI / 8) {
				angle -= 0.05;
			} else {
				attack = false;
			}
		} else {
			if (angle < Math.PI / 4) {
				angle += 0.05;
			}else {
				attack = true;
			}
		}
	}
	
	function MantisClaw()
	{
		super(new _bmpClaw() as Bitmap, new Point(70, 5));
	}
}