Exemple #1
0
    public List <WorldInfo> GetWorldList()
    {
        string           savePath  = GameConfig.Instance.GetSavePath();
        List <WorldInfo> worldList = new List <WorldInfo>();

        foreach (string folder in Directory.GetDirectories(savePath))
        {
            string worldJsonPath = folder + "/world.json";

            if (File.Exists(worldJsonPath))
            {
                string worldData       = File.ReadAllText(worldJsonPath);
                var    worldJson       = JSON.Parse(worldData);
                string worldFolderName = Path.GetFileName(folder);

                WorldInfo worldInfo = new WorldInfo(worldJson["name"], worldFolderName, worldJson["date"]);
                worldList.Add(worldInfo);
            }
        }

        worldList.Sort((world1, world2) => DateUtil.CompareStringDate(world2.date, world1.date));

        return(worldList);
    }