public void save(string filename) { Map newMap = new Map(); // create map dimentions MapMapDimentions dimentions = new MapMapDimentions(); dimentions.Height = 1; dimentions.Width = 1; newMap.MapDimentions = dimentions; // create surfaces MapSurfaces surfaces = new MapSurfaces(); // create background MapSurfacesBackgoundPicture backgroundPic = new MapSurfacesBackgoundPicture(); MapSurfacesBackgoundPictureAsset backgroundAsset = new MapSurfacesBackgoundPictureAsset(); MapSurfacesBackgoundPictureAssetScale backScale = new MapSurfacesBackgoundPictureAssetScale(); MapSurfacesBackgoundPictureAssetPosition backgroundPos = new MapSurfacesBackgoundPictureAssetPosition(); backgroundAsset.name = "smudgystars"; backScale.X = "1"; backScale.Y = "1"; backgroundPos.X = "0"; backgroundPos.Y = "0"; backgroundPic.Asset = backgroundAsset; surfaces.BackgoundPicture = backgroundPic; backgroundAsset.Scale = backScale; backgroundAsset.Position = backgroundPos; // create some walls MapSurfacesWall[] walls = new MapSurfacesWall[4]; createWall(ref walls, 0, "left", editor.leftWallPosition, editor.leftWall); createWall(ref walls, 1, "right", editor.rightWallPosition, editor.rightWall); createWall(ref walls, 2, "bottom", editor.bottomWallPosition, editor.bottomWall); createWall(ref walls, 3, "top", editor.topWallPosition, editor.topWall); MapSurfacesAsset[] obsticals = new MapSurfacesAsset[0]; surfaces.Obsticals = obsticals; surfaces.MapWalls = walls; newMap.Surfaces = surfaces; // create spawns MapSpawnPoint spawns = new MapSpawnPoint(); MapSpawnPointPlayer1 p1Spawn = new MapSpawnPointPlayer1(); p1Spawn.X = "0"; p1Spawn.Y = "100"; spawns.Player1 = p1Spawn; newMap.SpawnPoint = spawns; XmlSerializer serialiser = new XmlSerializer(typeof(Map)); serialiser.Serialize(new StreamWriter(filename), newMap); }
private void createBackground(ref SpriteObjects.Sprite back, MapSurfacesBackgoundPicture backSpec) { Vector2 backPos = new Vector2( Convert.ToInt32(backSpec.Asset.Position.X), Convert.ToInt32(backSpec.Asset.Position.Y) ); float backScaleX = (float)Convert.ToDecimal(backSpec.Asset.Scale.X); float backScaleY = (float)Convert.ToDecimal(backSpec.Asset.Scale.Y); float spriteRotation = (float)Convert.ToDecimal(backSpec.Asset.Rotation); back = new SpriteObjects.Sprite(backPos, spriteRotation); back.WidthScale = backScaleX; back.HeightScale = backScaleY; }