示例#1
0
文件: MapDesc.cs 项目: joninvski/padi
 public MapDesc(string mapName, string configName, string idServidorResponsavel, string idJogoAssociado)
 {
     _mapa = MapLoader.LoadMap(mapName, idServidorResponsavel);
      _config = ConfigLoader.LoadConfig(configName);
      _idJogoAssociado = idJogoAssociado;
      InicializaOuroTesouroSalas();
 }
示例#2
0
        public static ConfigValues LoadConfig(string path)
        {
            Hashtable properties = new Hashtable();

            using (StreamReader sr = File.OpenText(path)) {
                string s = "";
                while ((s = sr.ReadLine()) != null) {
                    string[] prop = s.Split('=');
                    try {
                        if (prop != null && prop[0] != null && prop[1] != null) {
                            properties.Add(prop[0],Int32.Parse((string)prop[1]));
                        }
                    } catch (FormatException) {
                        throw new ParseErrorException("Error converting value '" + prop[1] + "'");
                    }
                }
            }

            try {
                ConfigValues config = new ConfigValues();
                config.PontAbrir = (int) properties["PontAbrir"];
                config.PontMaxima = (int) properties["PontMaxima"];
                config.PontTesouro = (int) properties["PontTesouro"];
                config.PontVeneno = (int) properties["PontVeneno"];
                config.SalaInicial = (int) properties["SalaInicial"];
                return config;
            } catch (NullReferenceException) {
                throw new ConfigErrorException("Initialization property not defined.");
            }
        }