示例#1
0
        public void WriteGameConfig(string gameDirPath, ShikiGameConfig gameConfig)
        {
            string gameConfigPath = Path.Combine(gameDirPath, gameConfigFileName);

            Directory.CreateDirectory(gameDirPath);
            string jsonString = JsonSerializer.Serialize <ShikiGameConfig>(gameConfig, jsonSerializerOptions);

            File.WriteAllText(gameConfigPath, jsonString);
        }
示例#2
0
        public ShikiGameConfig ReadGameConfig(string gameDirPath)
        {
            ShikiGameConfig gameConfig;
            string          gameConfigPath = Path.Combine(gameDirPath, gameConfigFileName);

            if (File.Exists(gameConfigPath))
            {
                string jsonString = File.ReadAllText(gameConfigPath);
                gameConfig = JsonSerializer.Deserialize <ShikiGameConfig>(jsonString, jsonSerializerOptions);
            }
            else
            {
                gameConfig = new ShikiGameConfig();
            }
            return(gameConfig);
        }