Ejemplo n.º 1
0
    /// <summary>
    /// Saves map to xml file. Gets name from 3D input field.
    /// </summary>
    public void SaveMap()
    {
        if (mapName.Length == 0 || mapName.IndexOfAny(Path.GetInvalidFileNameChars()) != -1)
        {
            msg.SetText("Map name is not correct!", 4f, Color.red);
            return;
        }

        mapPath = PathToMapsDir + "/" + Path.GetFileNameWithoutExtension(mapName) + ".xml";

        Map map = new Map(mapName, elementTypes, biomeType, difficulty);

        if (map.IsMapDefined)
        {
            MapSerializer mapSerializer = new MapSerializer(mapPath);
            mapSerializer.Serialize(map);
            msg.SetText($"Saved map correctly in: {mapPath}", 6f, Color.green);

            MakeMapMiniature();

            RankingManager.RemoveAllRecords(map.name);
            SaveLoadManager.ClearSave(map);
        }
        else
        {
            msg.SetText("Cannot save this map due to some problems!", 4f, Color.red);
        }
    }