Exemplo n.º 1
0
        protected override void OnSubModuleLoad()
        {
            //set default config params
            List <int> defaultEnabledTroops = new List <int>();

            config = new BerzerkerHealConfig(0.25f, 0, false, false, defaultEnabledTroops);

            //read xml and get heal mult.
            XmlDocument doc = new XmlDocument();

            doc.PreserveWhitespace = true;
            try {
                String CurrentFilePath = Directory.GetCurrentDirectory();
                Console.WriteLine("The current directory is {0}", CurrentFilePath);
                doc.Load("../../modules/BerzerkerHeal/config.xml");
                //scan through xml to find heal rate.
                foreach (XmlNode n in doc.DocumentElement.ChildNodes)
                {
                    if (n.Attributes != null)
                    {
                        foreach (XmlAttribute a in n.Attributes)
                        {
                            if (a.Name.Equals("HealRate"))
                            {
                                config.healMult = float.Parse(a.Value);
                            }
                            if (a.Name.Equals("EnableForAllUnits"))
                            {
                                config.EnableForAllUnits = int.Parse(a.Value);
                            }
                            if (a.Name.Equals("EnableForPlayer"))
                            {
                                config.EnableForPlayer = bool.Parse(a.Value);
                            }
                            if (a.Name.Equals("VerboseLogging"))
                            {
                                config.VerboseLogging = bool.Parse(a.Value);
                            }
                            if (a.Name.Equals("EnabledUnit"))
                            {
                                //uses a hash code list so that there are less string compares and it only compares ints (32 bit vs 128+ bit)
                                config.EnabledUnits.Add(a.Value.GetHashCode());
                            }
                        }
                    }
                }
            }
            catch (System.IO.FileNotFoundException)
            {
                defaultEnabledTroops.Add("Sturgian Berserker".GetHashCode());
                defaultEnabledTroops.Add("Sturgian Ulfhednar".GetHashCode());
            }
            int x = 3;
        }
Exemplo n.º 2
0
 public AC_HealOnHit(Agent agent, BerzerkerHealConfig _config) : base(agent)
 {
     config = _config;
 }