Пример #1
0
    private void LoadConfigurationFile()
    {
        Dictionary jsonMap = JSONUtil.ParseFileAs <Dictionary>(CONFIG_FILE_PATH);

        if (jsonMap != null)
        {
            try
            {
                if (jsonMap.Contains("gameLevel"))
                {
                    gameConfig.GameLevel = Convert.ToByte(jsonMap["gameLevel"]);
                }

                if (jsonMap.Contains("playerMark"))
                {
                    gameConfig.PlayerMark = Convert.ToSByte(jsonMap["playerMark"]);
                }

                if (jsonMap.Contains("WhoStarts"))
                {
                    gameConfig.WhoStarts = Convert.ToSByte(jsonMap["WhoStarts"]);
                }

                return;
            }
            catch
            {
                gameConfig = new GameConfig();
                GD.Print("Problems loading configuration file");
            }
        }


        CreateDefaultConfigurationFile();
    }