/// <summary>
        /// Load the map form xml file
        /// </summary>
        private ViewMap LoadMapFromXML(string path)
        {
            var map = new ViewMap();
            Map m = Deserialize(path);

            map.BitmapSources = LoadTexture.Load(_baseFolder);
            map.ObjectSetting = m.Settings;

            foreach (BirdSetting o in m.Birds)
            {
                map.Birds.Add(new ViewBirdSetting(o, map.ViewObjectSettings[o.Type]));
            }
            foreach (PigSetting o in m.Pigs)
            {
                map.Pigs.Add(new ViewPigSetting(o, map.ViewObjectSettings[o.Type]));
            }
            foreach (BlockSetting o in m.Blocks)
            {
                map.Blocks.Add(new ViewBlockSetting(o, map));
            }

            map.Width = m.MapWidth;
            map.Height = m.MapHeigth;
            map.Gravity = m.Gravity;

            map.Path = path;

            return map;
        }
 public ViewBlockSetting(BlockSetting blockSetting, ViewMap map)
     : base(blockSetting, map.ViewObjectSettings[blockSetting.Material.ToString() + blockSetting.Type],
         blockSetting.Type)
 {
     BlockSetting = blockSetting;
     CurrentMap = map;
 }
 public static ViewSetting CreatePigSetting(ViewMap map, object type, double x, double y, float angle,
                                            object source)
 {
     var o = new ViewPigSetting(new PigSetting
                                    {
                                        Type = (PigType) type,
                                        Position = new Vector2((float) x, (float) y),
                                        Rotation = angle
                                    }, map.ViewObjectSettings[type]);
     map.Pigs.Add(o);
     return o;
 }
 public static ViewSetting CreateBlockSetting(ViewMap map, object type, double x, double y, float angle,
                                              object material)
 {
     var o = new ViewBlockSetting(new BlockSetting
                                      {
                                          Type = (BlockType) type,
                                          Position = new Vector2((float) x, (float) y),
                                          Rotation = angle,
                                          Material = (Material) material
                                      }, map);
     map.Blocks.Add(o);
     return o;
 }
 /// <summary>
 /// Save runing map to xml file
 /// </summary>
 private void SaveMapToXML(ViewMap map)
 {
     var m = new Map
                 {
                     Gravity = map.Gravity,
                     MapHeigth = map.Height,
                     MapWidth = map.Width,
                     Birds = map.Birds.Select(x => x.Setting).ToArray(),
                     Pigs = map.Pigs.Select(x => x.Setting).ToArray(),
                     Blocks = map.Blocks.Select(x => x.Setting).ToArray(),
                     Settings = map.ObjectSetting
                 };
     Serialize(m, map.Path);
 }