Ejemplo n.º 1
0
        public static UnitGroup FromIniSection(Ini.Section sec)
        {
            UnitGroup ug = new UnitGroup(sec["Name"].Value);

            ug.Side                  = (Side)int.Parse(sec["Side"].Value);
            ug.Aggressiveness        = (Aggressiveness)int.Parse(sec["Aggressiveness"].Value);
            ug.LoopForever           = (int.Parse(sec["LoopForever"].Value) != 0);
            ug.CreateAtLevelLoad     = (int.Parse(sec["CreateAtLevelLoad"].Value) != 0);
            ug.RandomGroup           = (int.Parse(sec["RandomGroup"].Value) != 0);
            ug.Spawn                 = (int.Parse(sec["Spawn"].Value) != 0);
            ug.ReplaceDestroyedGroup = (int.Parse(sec["ReplaceGroup"].Value) != 0);
            if (sec["SpawnArea"] != null)
            {
                ug.SpawnArea = CaTypeArea.GetAreaNameFromIndex(int.Parse(sec["SpawnArea"].Value));
            }
            ug.Health = int.Parse(sec["Health"].Value);

            // Units

            string strUTC = null;

            if (sec["Units"] != null)
            {
                strUTC = sec["Units"].Value;
            }
            if (strUTC != null)
            {
                Regex  re   = new Regex(@"^(?<count>\d+),(?<end>.*)$");
                Match  m    = re.Match(strUTC);
                string strT = m.Groups["end"].Value;
                while (strT.Length != 0)
                {
                    UnitTypeAndCount utc = new UnitTypeAndCount();
                    strT = utc.FromSaveString(strT);
                    ug.UnitTypeAndCounts.Add(utc);
                    re   = new Regex(@"^\s*,(?<end>.*)$");
                    m    = re.Match(strT);
                    strT = m.Groups["end"].Value;
                }
            }

            // UnitGroup actions

            foreach (Ini.Property prop in sec.Properties)
            {
                if (prop.Name != "A")
                {
                    continue;
                }
                CaBase cab = UnitGroupActionLoader.LoadIni(prop.Value);
                ug.Actions.Add(cab);
            }
            return(ug);
        }
Ejemplo n.º 2
0
        private void buttonAddUnit_Click(object sender, System.EventArgs e)
        {
            int n = listBoxUnits.SelectedIndex;

            if (n >= 0)
            {
                UnitTypeAndCount uct = (UnitTypeAndCount)m_ugSelected.UnitTypeAndCounts[n];
                uct.c++;
                m_ugm.SetModified();
                InitUnitsListBox(n);
            }
        }
Ejemplo n.º 3
0
        public object Clone()
        {
            UnitTypeAndCount utc = new UnitTypeAndCount(ut, c);

            return(utc);
        }
Ejemplo n.º 4
0
 public object Clone()
 {
     UnitTypeAndCount utc = new UnitTypeAndCount(ut, c);
     return utc;
 }
Ejemplo n.º 5
0
        public static UnitGroup FromIniSection(Ini.Section sec)
        {
            UnitGroup ug = new UnitGroup(sec["Name"].Value);
            ug.Side = (Side)int.Parse(sec["Side"].Value);
            ug.Aggressiveness = (Aggressiveness)int.Parse(sec["Aggressiveness"].Value);
            ug.LoopForever = (int.Parse(sec["LoopForever"].Value) != 0);
            ug.CreateAtLevelLoad = (int.Parse(sec["CreateAtLevelLoad"].Value) != 0);
            ug.RandomGroup = (int.Parse(sec["RandomGroup"].Value) != 0);
            ug.Spawn = (int.Parse(sec["Spawn"].Value) != 0);
            ug.ReplaceDestroyedGroup = (int.Parse(sec["ReplaceGroup"].Value) != 0);
            if (sec["SpawnArea"] != null) {
                ug.SpawnArea = CaTypeArea.GetAreaNameFromIndex(int.Parse(sec["SpawnArea"].Value));
            }
            ug.Health = int.Parse(sec["Health"].Value);

            // Units

            string strUTC = null;
            if (sec["Units"] != null) {
                strUTC = sec["Units"].Value;
            }
            if (strUTC != null) {
                Regex re = new Regex(@"^(?<count>\d+),(?<end>.*)$");
                Match m = re.Match(strUTC);
                string strT = m.Groups["end"].Value;
                while (strT.Length != 0) {
                    UnitTypeAndCount utc = new UnitTypeAndCount();
                    strT = utc.FromSaveString(strT);
                    ug.UnitTypeAndCounts.Add(utc);
                    re = new Regex(@"^\s*,(?<end>.*)$");
                    m = re.Match(strT);
                    strT = m.Groups["end"].Value;
                }
            }

            // UnitGroup actions

            foreach (Ini.Property prop in sec.Properties) {
                if (prop.Name != "A") {
                    continue;
                }
                CaBase cab = UnitGroupActionLoader.LoadIni(prop.Value);
                ug.Actions.Add(cab);
            }
            return ug;
        }