Exemplo n.º 1
0
    public TrackSerializer(Track track)
    {
        this.track = track;

        terrainSerializer = new TerrainSerializer();
        directoryHelper   = new TrackFolderHelper();
        trackCompressor   = new TrackFileCompressor();
    }
Exemplo n.º 2
0
    public TrackDTO LoadWorld(string name)
    {
        var trackPath = directoryHelper.GetTrackPath(name);

        XmlSerializer serializer = new XmlSerializer(typeof(TrackDTO));

        TrackFileCompressor trackCompressor          = new TrackFileCompressor();
        TrackData           decompressedTrackStreams = trackCompressor.DecompressPackage(trackPath);
        TrackDTO            mapObject = (TrackDTO)serializer.Deserialize(new MemoryStream(decompressedTrackStreams.ObjectsData));

        track.Terrain.terrainData.SetHeights(0, 0, terrainSerializer.DeserializeHeightMap(decompressedTrackStreams.HeightMapData, track.HeightMapSize));
        track.Terrain.terrainData.SetAlphamaps(0, 0, terrainSerializer.DeserializeTextureMap(decompressedTrackStreams.TextureMapData, track.TextureMapSize));

        return(mapObject);
    }