Ejemplo n.º 1
0
        public bool Load(string basePath)
        {
            var       fullPath = Path.Combine(basePath, "Data/Drop/weapon_settings.xml");
            XDocument document = XDocument.Load(fullPath);

            settings = new ConcurrentDictionary <Workshop, WeaponWorkshopSetting>();

            var dmp1 = document.Element("settings").Elements("param").Select(pe => {
                switch (pe.GetString("name"))
                {
                case "max_level":
                    m_MaxLevel = pe.GetInt("value");
                    break;

                case "damage_od_pt_max":
                    m_DamageOdPtMax = pe.GetInt("value");
                    break;
                }
                return(pe);
            }).ToList();

            var dump = document.Element("settings").Elements("workshop").Select(we => {
                WeaponWorkshopSetting wset = new WeaponWorkshopSetting(we);
                settings.TryAdd(wset.workshop, wset);
                return(we);
            }).ToList();

            /*
             * var lst = document.Element("settings").Elements("workshop").Select(e => {
             *  Workshop workshop = (Workshop)Enum.Parse(typeof(Workshop), e.GetString("name"));
             *  WeaponWorkshopSetting set = new WeaponWorkshopSetting {
             *      workshop = workshop,
             *      base_damage = e.Element("base_damage").GetFloat("value"),
             *      base_optimal_distance = e.Element("base_optimal_distance").GetFloat("value"),
             *      damage_points_value = e.Element("damage_points_value").GetFloat("value"),
             *      optimal_distance_points_value = e.Element("optimal_distance_points_value").GetFloat("value"),
             *      base_damage_factor = e.Element("base_damage_factor").GetFloat("value"),
             *      base_optimal_distance_factor = e.Element("base_optimal_distance_factor").GetFloat("value"),
             *      damage_points_factor = e.Element("damage_points_factor").GetFloat("value"),
             *      optimal_distance_points_factor = e.Element("optimal_distance_points_factor").GetFloat("value"),
             *      base_crit_chance = e.Element("base_crit_chance").GetFloat("value")
             *  };
             *  if(!settings.TryAdd(workshop, set)) {
             *      throw new Exception("Error of adding WeaponWorkshopSetting to dictionary");
             *  }
             *  return workshop;
             * }).ToList();
             */

            this.loaded = true;
            return(this.loaded);
        }
Ejemplo n.º 2
0
 public bool TryGetSetting(Workshop workshop, out WeaponWorkshopSetting setting)
 {
     return(settings.TryGetValue(workshop, out setting));
 }