package game.GameMain.LevelTiles
{
	import flash.display.BitmapData;
	import flinjin.algorithms.collisions.BruteForce;
	import flinjin.graphics.Layer;
	import flinjin.graphics.Sprite;
	import flinjin.types.BoundingRect;
	
	/**
	 * ...
	 * @author Michael Miriti
	 */
	public class LevelTile extends Layer
	{
		public var Bmp:Sprite = null;
		public var Mask:BitmapData = null;
		
		public function getPixelAt(nx:int, ny:int):uint
		{
			if (Mask != null)
			{
				if ((nx >= 0) && (nx < Mask.width) && (ny >= 0) && (ny < Mask.height))
				{
					if (_flipHorizontal)
					{
						return Mask.getPixel32(width - nx, ny);
					}
					else
					{
						return Mask.getPixel32(nx, ny);
					}
				}
				else
				{
					return 0;
				}
			}
			else if (Bmp != null)
			{
				if ((nx >= 0) && (nx < Bmp.width) && (ny >= 0) && (ny < Bmp.height))
				{
					return Bmp.lastDrawedBitmap.getPixel32(nx, ny);
				}
				else
				{
					return 0;
				}
			}
			else
			{
				return 0;
			}
		}
		
		public function InitMobs():void
		{
		
		}
		
		public function LevelTile(layerWidth:uint, layerHeight:uint)
		{
			super(layerWidth, layerHeight);
			
			if (Math.floor(Math.random() * 10) % 2 == 0)
			{
				_flipHorizontal = true;
			}
		}
	}

}