package game.GameMain
{
	import flash.geom.Rectangle;
	import flinjin.algorithms.collisions.BruteForce;
	import flinjin.graphics.Sprite;
	import flinjin.Flinjin;
	import flinjin.graphics.Layer;
	import flinjin.types.BoundingRect;
	import game.GameMain.LevelTiles.LevelParts.Leaf;
	import game.GameMain.Mobs.MasquitoMob;
	
	/**
	 * ...
	 * @author Michael Miriti <m.s.miriti@gmail.com>
	 */
	public class TileLevel extends Layer
	{
		private var _shiftY:Number = 0;
		public var LevelLayer:LevelScroll = new LevelScroll();
		public var PlayerLayer:Layer;
		public var Player:AntPlayer = new AntPlayer();
		
		public var scrollSpeed:Number = 2;
		
		private var _testMasquit:MasquitoMob;
		
		override public function Move():void
		{
			if (PlayerLayer.shiftY > 200) {
				LevelLayer.shiftY += scrollSpeed;
				PlayerLayer.shiftY += scrollSpeed;
				(_parentSprite as GameMain).scrollY += scrollSpeed;
			}
			
			if (PlayerLayer.shiftY + Player.y < Flinjin.sceneHeight / 4)
			{
				var _dy:Number = (Flinjin.sceneHeight / 4) - (PlayerLayer.shiftY + Player.y);
				
				LevelLayer.shiftY += _dy;
				PlayerLayer.shiftY += _dy;
				(_parentSprite as GameMain).scrollY += _dy;
			}
			
			super.Move();
		}
		
		public function TileLevel()
		{
			super(Flinjin.sceneWidth, Flinjin.sceneHeight);
			PlayerLayer = new Layer(Flinjin.sceneWidth, Flinjin.sceneHeight);
			PlayerLayer.setCollisionsAlgorithm(new BruteForce());
			
			addSprite(LevelLayer);			
			PlayerLayer.addSprite(Player);
			addSprite(PlayerLayer);
		}
	
	}

}