Exemple #1
0
        public bool Load(string basePath)
        {
            string    fullPath = Path.Combine(basePath, "Data/Drop/module_settings.xml");
            XDocument document = XDocument.Load(fullPath);

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

            XElement settingsElement = document.Element("settings");

            var dmp1 = settingsElement.Elements("param").Select(e => {
                switch (e.GetString("name"))
                {
                case "max_level":
                    m_MaxLevel = e.GetInt("value");
                    break;

                case "hp_speed_cargo_pt_max":
                    m_HpSpeedCargoPtMax = e.GetInt("value");
                    break;

                case "add_point_max":
                    m_AddPointMax = e.GetInt("value");
                    break;
                }
                return(e);
            }).ToList();

            var dump = settingsElement.Elements("workshop").Select(we => {
                ModuleSettingData data = new ModuleSettingData(we);
                settings.TryAdd(data.workshop, data);
                return(data);
            }).ToList();

            /*
             * var lst = document.Element("settings").Elements("workshop").Select(e => {
             *  Workshop workshop = (Workshop)Enum.Parse(typeof(Workshop), e.GetString("name"));
             *  ModuleSettingData data = new ModuleSettingData {
             *      workshop = workshop,
             *      base_hp = e.Element("base_hp").GetFloat("value"),
             *      base_speed = e.Element("base_speed").GetFloat("value"),
             *      base_cargo = e.Element("base_cargo").GetFloat("value"),
             *      base_hp_factor = e.Element("base_hp_factor").GetFloat("value"),
             *      base_speed_factor = e.Element("base_speed_factor").GetFloat("value"),
             *      base_cargo_factor = e.Element("base_cargo_factor").GetFloat("value"),
             *      //resistance_aux_number = e.Element("resistance_aux_number").GetFloat("value"),
             *      critical_chance_aux_number = e.Element("critical_chance_aux_number").GetFloat("value"),
             *      bonus_aux_number = e.Element("bonus_aux_number").GetFloat("value"),
             *      slot_settings = LoadSlotSettings(e.Element("slots"))
             *  };
             *  if(!settings.TryAdd(workshop, data)) {
             *      throw new Exception("Error of adding ModuleSettingData to dictionary");
             *  }
             *  return workshop;
             * }).ToList();*/

            mLoaded = true;
            return(true);
        }
Exemple #2
0
 public bool TeyGetWorkshopData(Workshop workshop, out ModuleSettingData data)
 {
     return(settings.TryGetValue(workshop, out data));
 }