public static void SaveMap(FileStream fileStream) { SerializableTileMap _SerializableTileMap = new SerializableTileMap(MapLayers, MapWidth, MapHeight, TileWidth, TileHeight, Gravity, MapLayerCollection); XmlSerializer _XmlSerializer = new XmlSerializer(typeof(SerializableTileMap)); _XmlSerializer.Serialize(fileStream, _SerializableTileMap); fileStream.Close(); }
/// <summary> /// Initialization used by the MapEditor when loading an existing map. /// </summary> /// <param name="tileTexture"></param> /// <param name="serializableTileMap"></param> /// <param name="graphicsDevice"></param> public static void Initialize(Texture2D tileTexture, SerializableTileMap serializableTileMap, GraphicsDevice graphicsDevice) { Initialize( tileTexture, serializableTileMap.MapLayers, serializableTileMap.MapWidth, serializableTileMap.MapHeight, serializableTileMap.TileWidth, serializableTileMap.TileHeight, graphicsDevice); }
public static void LoadLayer(SerializableTileMap serializableTileMap, int layerNumber) { int _LayerPosition = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.LayerNumber; MapLayerCollection[_LayerPosition] = new MapLayer(layerNumber); MapLayerCollection[_LayerPosition].MapSquareCollection = serializableTileMap.ConvertSimpleArrayIntoMultidimensionalArray(serializableTileMap.SerializableMapLayerCollection[layerNumber].SerializableMapSquareCollection); MapLayerCollection[_LayerPosition].ShowLayer = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.ShowLayer; MapLayerCollection[_LayerPosition].AutoScrolling = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.AutoScrolling; MapLayerCollection[_LayerPosition].AutoScrollingVelocity = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.AutoScrollingVelocity; MapLayerCollection[_LayerPosition].AlphaValue = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.AlphaValue; MapLayerCollection[_LayerPosition].LayerNumber = serializableTileMap.SerializableMapLayerCollection[layerNumber].MapLayer.LayerNumber; MapLayerCollection[_LayerPosition].TintColor.R = (byte)serializableTileMap.SerializableMapLayerCollection[layerNumber].TintColor.X; MapLayerCollection[_LayerPosition].TintColor.G = (byte)serializableTileMap.SerializableMapLayerCollection[layerNumber].TintColor.Y; MapLayerCollection[_LayerPosition].TintColor.B = (byte)serializableTileMap.SerializableMapLayerCollection[layerNumber].TintColor.Z; }
public static void LoadMap(SerializableTileMap serializableTileMap) { MapLayers = serializableTileMap.MapLayers; MapWidth = serializableTileMap.MapWidth; MapHeight = serializableTileMap.MapHeight; TileWidth = serializableTileMap.TileWidth; TileHeight = serializableTileMap.TileHeight; Gravity = serializableTileMap.Gravity; Camera.WorldRectangle = new Rectangle(0, 0, TileWidth * MapWidth, TileHeight * MapHeight); Camera.Position = Vector2.Zero; MapLayerCollection = new MapLayer[serializableTileMap.SerializableMapLayerCollection.Length]; for (int layer = 0; layer < serializableTileMap.SerializableMapLayerCollection.Length; layer++) { LoadLayer(serializableTileMap, layer); } }