Пример #1
0
    public void SaveRoom()
    {
        Room_Editor_Saver saveData = Room_Editor_Saver.instance;

        saveData.ReadData();
        //Save Data
        if (saveData.editorData.roomKeys.Contains(roomName.text))
        {
            //Replace the room at that point
            int index = saveData.editorData.roomKeys.IndexOf(roomName.text);

            Room_Editor_Data.TilePositions tileData = new Room_Editor_Data.TilePositions();
            tileData.groundPositions     = tiles;
            tileData.backgroundPositions = backTiles;

            saveData.editorData.tilePositions[index] = tileData;
        }
        else
        {
            //Doesn't exist in our savedata so we add a new one.
            Room_Editor_Data.TilePositions tileData = new Room_Editor_Data.TilePositions();
            tileData.groundPositions     = tiles;
            tileData.backgroundPositions = backTiles;

            saveData.editorData.roomKeys.Add(roomName.text);
            saveData.editorData.objects.Add(null);
            saveData.editorData.objectPositions.Add(new Vector3Int(0, 0, 0));
            saveData.editorData.tilePositions.Add(tileData);
        }

        saveData.SaveData();
    }
Пример #2
0
    public void LoadRoom()
    {
        //Loading in a room
        Room_Editor_Saver saveData = Room_Editor_Saver.instance;

        saveData.ReadData();

        Tilemap previousSelection = selectedTiles;

        int index = saveData.editorData.roomKeys.IndexOf(roomName.text);

        groundTiles.ClearAllTiles();
        backgroundTiles.ClearAllTiles();
        tiles.Clear();
        backTiles.Clear();

        //All the ground tiles
        foreach (Vector3Int pos in saveData.editorData.tilePositions[index].groundPositions)
        {
            selectedTiles = groundTiles;
            DrawTile(pos);
        }

        UpdateTiles();

        //All the background tiles
        foreach (Vector3Int pos in saveData.editorData.tilePositions[index].backgroundPositions)
        {
            selectedTiles = backgroundTiles;
            DrawTile(pos);
        }

        UpdateTiles();

        selectedTiles = previousSelection;
    }