Esempio n. 1
0
        private static void LoadCombos(Bot bot, string XMLFilename)
        {
            var xmldoc = new XmlDocument();
            xmldoc.Load(XMLFilename);
            foreach (XmlNode comboXml in xmldoc.DocumentElement.SelectNodes("//Combo"))
            {
                var combo = new Combo();
                ComboType tmp = 0;
                string stInput = "";
                if (comboXml.ParentNode.LocalName == "Starter")
                {
                    foreach (XmlAttribute attr in comboXml.ParentNode.Attributes)
                    {
                        PropertyInfo propertyInfo = combo.GetType().GetProperty(attr.Name);
                        if (propertyInfo.PropertyType.IsEnum)
                            propertyInfo.SetValue(combo, Enum.Parse(typeof(ComboType), attr.Value));
                        else
                            propertyInfo.SetValue(combo, Convert.ChangeType(attr.Value, propertyInfo.PropertyType), null);
                    }
                    tmp = combo.Type;
                    stInput = combo.Input;

                }

                foreach(XmlAttribute attr in comboXml.Attributes)
                {
                    PropertyInfo propertyInfo = combo.GetType().GetProperty(attr.Name);
                    if(propertyInfo.PropertyType.IsEnum)
                        propertyInfo.SetValue(combo, Enum.Parse(typeof(ComboType), attr.Value));
                    else
                        propertyInfo.SetValue(combo, Convert.ChangeType(attr.Value, propertyInfo.PropertyType), null);
                }
                combo.Type = combo.Type | tmp;
                if(stInput != "")
                    combo.Input = stInput + "."+combo.Input;
                bot.getComboList().Add(combo);
            }
        }
Esempio n. 2
0
 protected virtual float scoreCombo(Combo combo, int startup = Int32.MaxValue)
 {
     return 1;
 }