private void PlottLevelData(Level lvl)
        {
            int TotalColumns = lvl.Width / Assets.CELLSIZE;
            int TotalRows = lvl.Height / Assets.CELLSIZE;

            //Create Cell Matrix
            int[,] matrix = new int[TotalRows, TotalColumns];
            for (int i = 0; i < TotalRows; i++)
                for (int j = 0; j < TotalColumns; j++)
                    matrix[i, j] = 0;

            //Create Physics Object from Entity
            _ballEntity = null;
            bool CreateRectangle = false;
            string TextureForRectangle = string.Empty;
            GameObjectData additionData;
            Body body;
            Vertices vertices;

            foreach (Entity item in lvl.LevelEntities)
            {
                CreateRectangle = false;
                TextureForRectangle = string.Empty;
                additionData = new GameObjectData(GameObjectType.NONE);

                body = BodyFactory.CreateBody(World);
                body.SleepingAllowed = true;

                switch (item.Type)
                {
                    case EntityType.Obstacle1:
                    case EntityType.Obstacle2:
                    case EntityType.Obstacle3:
                    case EntityType.Obstacle4:
                    case EntityType.Obstacle5:
                    case EntityType.Obstacle6:
                        TextureForRectangle = Assets.Obstacle(item.Type);
                        CreateRectangle = true;
                        additionData.Type = GameObjectType.NONE;
                        break;
                    case EntityType.SpikeRight:
                        vertices = CreateRightSpike(matrix, body, item);
                        break;
                    case EntityType.SpikeLeft:
                        vertices = CreateLeftSpike(matrix, body, item);
                        break;
                    case EntityType.SpikeUp:
                        vertices = CreateUpSpike(matrix, body, item);
                        break;
                    case EntityType.SpikeDown:
                        vertices = CreateDownSpike(matrix, body, item);
                        break;
                    case EntityType.FloorLeft:
                    case EntityType.FloorMiddle:
                    case EntityType.FloorRight:
                        CreateFloor(body, item);

                        //Fill Matrix Position
                        matrix[item.Y, item.X] = 1;
                        matrix[item.Y + 1, item.X] = 1;
                        break;
                    case EntityType.Ball:
                        _ballEntity = item;

                        //Fill Matrix Position
                        matrix[item.Y, item.X] = 1;
                        matrix[item.Y + 1, item.X] = 1;
                        matrix[item.Y, item.X + 1] = 1;
                        matrix[item.Y + 1, item.X + 1] = 1;
                        break;
                    case EntityType.WoodDiamond:
                        CreateDiamond(body, item);

                        //Fill Matrix Position
                        matrix[item.Y, item.X] = 1;
                        matrix[item.Y + 1, item.X] = 1;
                        matrix[item.Y, item.X + 1] = 1;
                        matrix[item.Y + 1, item.X + 1] = 1;
                        break;
                }

                if (CreateRectangle)
                {
                    if (item.Type == EntityType.Obstacle1 || item.Type == EntityType.Obstacle2 || item.Type == EntityType.Obstacle3 ||
                        item.Type == EntityType.Obstacle4 || item.Type == EntityType.Obstacle5 || item.Type == EntityType.Obstacle6)
                    {
                        FixtureFactory.CreateRectangle(ConvertUnits.ToSimUnits(Assets.CELLSIZE - 2), 0.1f, Assets.DENSITY, new Vector2(0, 1.7f),
                            body, new RenderMaterial(GetTexture(TextureForRectangle), TextureForRectangle, Assets.CELLSIZE_FARSEER)
                            {
                                Color = Color.White,
                                UserData = new GameObjectData(GameObjectType.SOLIDOBJECT)
                            });
                    }

                    FixtureFactory.CreateRectangle(Assets.CELLSIZE_FARSEER, Assets.CELLSIZE_FARSEER,
                                                        Assets.DENSITY, new Vector2(0, 0), body,
                                                        new RenderMaterial(GetTexture(TextureForRectangle), TextureForRectangle,
                                                                            Assets.CELLSIZE_FARSEER)
                                                        {
                                                            UserData = additionData
                                                        });
                    body.IsStatic = true;
                    body.Position = Camera2D.ConvertScreenToWorld(new Vector2(item.X * Assets.CELLSIZE + Assets.CELLSIZE / 2, item.Y * Assets.CELLSIZE + Assets.CELLSIZE / 2));

                    //Fill Matrix Position
                    matrix[item.Y, item.X] = 1;
                }

                if (body != null)
                {
                    foreach (Fixture fixture in body.FixtureList)
                    {
                        fixture.Restitution = Assets.RESTITUTION;
                        fixture.Friction = Assets.FRICTION;
                    }
                }

            }

            //Create Ball.
            CreateBall();

            //Create Solid Floor where no other object placed.
            CreateSolidFloor(TotalColumns, TotalRows, matrix);

            //Cerate Level Completion wall.
            CreateLevelCompletedWall(TotalColumns, TotalRows);
        }
        private void CreateFloor(Body body, Entity item)
        {
            string Asset = string.Empty;
            if (item.Type == EntityType.FloorLeft) Asset = Assets.FLOORLEFT;
            if (item.Type == EntityType.FloorMiddle) Asset = Assets.FLOORMIDDLE;
            if (item.Type == EntityType.FloorRight) Asset = Assets.FLOORRIGHT;

            FixtureFactory.CreateRectangle(ConvertUnits.ToSimUnits(item.Width), ConvertUnits.ToSimUnits(item.Height), Assets.DENSITY,
                                            new Vector2(0, 0), body,
                                            new RenderMaterial(GetTexture(Asset), Asset, Assets.CELLSIZE_FARSEER * 2.1f)
                                            {
                                                Color = Color.White,
                                                UserData = new GameObjectData(GameObjectType.NONE)
                                            });
            foreach (Fixture fixture in body.FixtureList)
            {
                fixture.CollisionFilter.CollidesWith = Category.None;
                fixture.CollisionFilter.CollisionCategories = Category.None;
            }
            body.IsStatic = true;
            body.Position = Camera2D.ConvertScreenToWorld(new Vector2(item.X * Assets.CELLSIZE + item.Width / 2, item.Y * Assets.CELLSIZE + item.Height / 2));

            //Create Body just below the Hollo Floor to find when the ball fall into it.
            if (item.Type == EntityType.FloorMiddle)
            {
                Body fakebody = BodyFactory.CreateBody(World);
                fakebody.SleepingAllowed = true;
                FixtureFactory.CreateRectangle(ConvertUnits.ToSimUnits(Assets.CELLSIZE), 0.1f, Assets.DENSITY, new Vector2(0, 0),
                                fakebody, new RenderMaterial(GetTexture(Asset), Asset, Assets.CELLSIZE_FARSEER)
                                {
                                    Color = Color.White,
                                    UserData = new GameObjectData(GameObjectType.BOUNDARY_HOLLO)
                                });
                fakebody.IsStatic = true;
                fakebody.Position = Camera2D.ConvertScreenToWorld(new Vector2(item.X * Assets.CELLSIZE + item.Width,
                                                                                item.Y * Assets.CELLSIZE + item.Height));
            }
        }
        private Vertices CreateUpSpike(int[,] matrix, Body body, Entity item)
        {
            Vertices vertices;
            vertices = new Vertices(3);
            vertices.Add(new Vector2(-0.5f, 0.0f) * Assets.CELLSIZE_FARSEER);
            vertices.Add(new Vector2(0.5f, 0.0f) * Assets.CELLSIZE_FARSEER);
            vertices.Add(new Vector2(0.0f, 1.0f) * Assets.CELLSIZE_FARSEER);

            body.CreateFixture(new PolygonShape(vertices, Assets.DENSITY),
                new RenderMaterial(GetTexture(Assets.SPIKE_UP_WOOD), Assets.SPIKE_UP_WOOD, Assets.CELLSIZE_FARSEER * 2)
                {
                    UserData = new GameObjectData(GameObjectType.SPIKE)
                });
            body.IsStatic = true;
            body.Position = Camera2D.ConvertScreenToWorld(
                new Vector2(item.X * Assets.CELLSIZE + Assets.CELLSIZE / 2, item.Y * Assets.CELLSIZE + Assets.CELLSIZE));

            //Fill Matrix Position
            matrix[item.Y, item.X] = 1;
            return vertices;
        }
 private void CreateDiamond(Body body, Entity item)
 {
     //Texture Height 33 and Width 45
     FixtureFactory.CreateRectangle(ConvertUnits.ToSimUnits(45), ConvertUnits.ToSimUnits(33), Assets.DENSITY,
                         new Vector2(0, 0), body,
                         new RenderMaterial(GetTexture(Assets.WOOD_DIAMOND), Assets.WOOD_DIAMOND, Assets.CELLSIZE_FARSEER * 2)
                         {
                             Color = Color.White,
                             UserData = new GameObjectData(GameObjectType.DIAMOND)
                         });
     body.IsStatic = true;
     body.Position = Camera2D.ConvertScreenToWorld(new Vector2(item.X * Assets.CELLSIZE + item.Width / 2, item.Y * Assets.CELLSIZE + item.Height / 2));
 }