예제 #1
0
 private void SaveMap()
 {
     MapEditorSaving.MapInfo saveMapData = new MapEditorSaving.MapInfo();
     saveMapData.id        = mapID;
     saveMapData.mapName   = mapName;
     saveMapData.mapWidth  = Mathf.RoundToInt(mapDimensions.x);
     saveMapData.mapheight = Mathf.RoundToInt(mapDimensions.y);
     for (int y = 0; y < mapData.GetLength(1); y++)
     {
         for (int x = 0; x < mapData.GetLength(0); x++)
         {
             MapTile targetTile = mapData[x, y];
             if (targetTile != null && !targetTile.isTheMirrorVersion)
             {
                 MapEditorSaving.TileInfo newTile = new MapEditorSaving.TileInfo();
                 newTile.xPos     = x;
                 newTile.yPos     = y;
                 newTile.rotation = Mathf.RoundToInt(targetTile.transform.eulerAngles.z);
                 newTile.type     = targetTile.typeIndex;
                 saveMapData.tiles.Add(newTile);
             }
         }
     }
     MapEditorSaving.SaveFile(saveMapData, mapID.ToString());
 }
예제 #2
0
 private void LoadMap()
 {
     MapEditorSaving.MapInfo loadedMap = MapEditorSaving.LoadFile(mapID.ToString());
     if (loadedMap != null)
     {
         mapDimensions = new Vector2(loadedMap.mapWidth, loadedMap.mapheight);
         ResizeMap();
         mapName = loadedMap.mapName;
         mapID   = loadedMap.id;
         foreach (MapEditorSaving.TileInfo tile in loadedMap.tiles)
         {
             currentTileIndex = tile.type;
             Quaternion newRotation = Quaternion.Euler(new Vector3(0f, 0f, tile.rotation));
             CreateAtPosition(tile.xPos, tile.yPos, newRotation);
         }
         changedDataThisFrame = true;
     }
 }