Load() public static méthode

public static Load ( string path ) : Partition,
path string
Résultat Partition,
Exemple #1
0
        protected override bool LoadMap(string mapName)
        {
            mapName = Path.GetFileNameWithoutExtension(mapName);
            var path = $"maps/{mapName}.map";

            Console.Print(OutputLevel.Debug, "map", $"loading map='{path}'");

            using (var stream = Storage.OpenFile(path, FileAccess.Read))
            {
                if (stream == null)
                {
                    Console.Print(OutputLevel.Debug, "map", $"could not open map='{path}'");
                    return(false);
                }

                CurrentMap = MapContainer.Load(stream, out var error);
                if (CurrentMap == null)
                {
                    Console.Print(OutputLevel.Debug, "map", $"error with load map='{path}' ({error})");
                    return(false);
                }
                CurrentMap.MapName = mapName;
                Console.Print(OutputLevel.Debug, "map", $"successful load map='{path}' ({error})");

                return(true);
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            using (var stream = File.OpenRead($"{MAP_NAME}.map"))
            {
                if (stream == null)
                {
                    Debug.Error("map", $"could not open map='{MAP_NAME}'");
                }
                else
                {
                    var mapContainer = MapContainer.Load(stream, out var error);
                    if (mapContainer == null)
                    {
                        Debug.Error("map", $"error with load map='{MAP_NAME}' ({error})");
                    }
                    else
                    {
                        Debug.Log("map", $"successful load map='{MAP_NAME}' ({error})");
                        ShowMapInfo(mapContainer);
                        ExportImages(mapContainer);
                    }
                }
            }

            Console.ReadLine();
        }
    public static Partition LoadPartition(string path)
    {
        string    subPath   = "Resources/";
        string    extension = ".xml";
        Partition partition = new Partition();

        if (FileExist(subPath + path + extension))
        {
            var InstanceCollection = MapContainer.Load(subPath + path + extension);
            if (InstanceCollection != null)
            {
                partition      = InstanceCollection;
                partition.name = path;
            }
        }
        return(partition);
    }