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 createWall(ref SpriteObjects.Wall wall, MapSurfacesWall wallSpec) { Vector2 wallPos = new Vector2( Convert.ToInt32(wallSpec.Asset.Position.X), Convert.ToInt32(wallSpec.Asset.Position.Y) ); Vector2 scale = new Vector2( (float)Convert.ToDecimal(wallSpec.Asset.Scale.X), (float)Convert.ToDecimal(wallSpec.Asset.Scale.Y) ); float spriteRotation = (float)Convert.ToDecimal(wallSpec.Asset.Rotation); wall = new SpriteObjects.Wall(mWorld, wallPos, spriteRotation); wall.WidthScale = scale.X; wall.HeightScale = scale.Y; }
private void createWall(ref MapSurfacesWall[] wallArr, int index, String wallType, Point Wallposition, EditorWindow.Asset editorWall) { MapSurfacesWall wall = new MapSurfacesWall(); wall.walltype = wallType; MapSurfacesWallAsset wallAsset = new MapSurfacesWallAsset(); MapSurfacesWallAssetScale scale = new MapSurfacesWallAssetScale(); scale.X = 1M; scale.Y = 1M;// no idea wat M is ?? fix it later wallAsset.Scale = scale; wallAsset.name = "Maps/Map" + editorWall.mapNo + "/" + editorWall.fileName; wallAsset.Height = "1"; wallAsset.Width = "1"; MapSurfacesWallAssetPosition position = new MapSurfacesWallAssetPosition(); position.X = ((int)Wallposition.X).ToString(); position.Y = ((int)Wallposition.Y).ToString(); wallAsset.Position = position; wall.Asset = wallAsset; wallArr[index] = wall; }