public void ModifyUnitGroup(UnitGroup ugModify, UnitGroup ug)
 {
     int n = m_alsUnitGroups.IndexOf(ugModify);
     if (n >= 0)
         m_alsUnitGroups[n] = ug;
     SetModified();
 }
        public void ModifyUnitGroup(UnitGroup ugModify, UnitGroup ug)
        {
            int n = m_alsUnitGroups.IndexOf(ugModify);

            if (n >= 0)
            {
                m_alsUnitGroups[n] = ug;
            }
            SetModified();
        }
Beispiel #3
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);
        }
Beispiel #4
0
 private void listViewUnitGroups_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (listViewUnitGroups.SelectedItems.Count == 0)
     {
         m_ugSelected = null;
     }
     else
     {
         m_ugSelected = (UnitGroup)listViewUnitGroups.SelectedItems[0].Tag;
     }
     InitUnitGroupPanel();
 }
 public void LoadIni(Ini ini)
 {
     for (int index = 0; true; index++)
     {
         Ini.Section sec = ini["UnitGroup " + index];
         if (sec == null)
         {
             break;
         }
         UnitGroup ug = UnitGroup.FromIniSection(sec);
         AddUnitGroup(ug);
     }
 }
Beispiel #6
0
        public virtual UnitGroup Clone()
        {
            UnitGroup ug = new UnitGroup(m_strName);

            ug.m_side                   = m_side;
            ug.m_aggr                   = m_aggr;
            ug.m_fLoopForever           = m_fLoopForever;
            ug.m_fRandomGroup           = m_fRandomGroup;
            ug.m_fSpawn                 = m_fSpawn;
            ug.m_fCreateAtLevelLoad     = m_fCreateAtLevelLoad;
            ug.m_fReplaceDestroyedGroup = m_fReplaceDestroyedGroup;
            ug.m_strSpawnArea           = (string)m_strSpawnArea.Clone();
            ug.m_nHealth                = m_nHealth;
            foreach (UnitTypeAndCount utc in UnitTypeAndCounts)
            {
                ug.UnitTypeAndCounts.Add(utc.Clone());
            }
            foreach (CaBase cab in Actions)
            {
                ug.Actions.Add(cab.Clone());
            }
            return(ug);
        }
 public virtual UnitGroup Clone()
 {
     UnitGroup ug = new UnitGroup(m_strName);
     ug.m_side = m_side;
     ug.m_aggr = m_aggr;
     ug.m_fLoopForever = m_fLoopForever;
     ug.m_fRandomGroup = m_fRandomGroup;
     ug.m_fSpawn = m_fSpawn;
     ug.m_fCreateAtLevelLoad = m_fCreateAtLevelLoad;
     ug.m_fReplaceDestroyedGroup = m_fReplaceDestroyedGroup;
     ug.m_strSpawnArea = (string)m_strSpawnArea.Clone();
     ug.m_nHealth = m_nHealth;
     foreach (UnitTypeAndCount utc in UnitTypeAndCounts)
         ug.UnitTypeAndCounts.Add(utc.Clone());
     foreach (CaBase cab in Actions)
         ug.Actions.Add(cab.Clone());
     return ug;
 }
        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;
        }
Beispiel #9
0
        public override string ToSaveString()
        {
            LevelDoc lvld = (LevelDoc)DocManager.GetActiveDocument(typeof(LevelDoc));

            // Create a new UnitGroup

            int iug = lvld.UnitGroupManager.Items.Count;
            UnitGroup ug = new UnitGroup("__cuaa" + iug);
            ug.Spawn = ((CaTypeCreate)m_acat[0]).Result == CreateType.Spawn ? true : false;
            ug.SpawnArea = ((CaTypeArea)m_acat[2]).Area;
            ug.UnitTypeAndCounts.Add(new UnitTypeAndCount(((CaTypeUnitType)m_acat[1]).UnitType, 1));
            ug.Side = ((CaTypeOneSide)m_acat[3]).Side;
            ug.Health = ((CaTypeNumber)m_acat[4]).Value;
            ug.LoopForever = false;
            ug.ReplaceDestroyedGroup = false;
            ug.CreateAtLevelLoad = false;
            ug.Aggressiveness = Aggressiveness.Defender;
            ug.RandomGroup = false;
            lvld.UnitGroupManager.AddUnitGroup(ug);

            string strType = GetType().ToString();
            int ichDot = strType.IndexOf(".");
            strType = strType.Substring(ichDot + 1, strType.Length - ichDot - 1);
            return "kn" + strType + "," + iug.ToString();
        }
 private void listViewUnitGroups_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (listViewUnitGroups.SelectedItems.Count == 0)
         m_ugSelected = null;
     else
         m_ugSelected = (UnitGroup)listViewUnitGroups.SelectedItems[0].Tag;
     InitUnitGroupPanel();
 }
 public void RemoveUnitGroup(UnitGroup ug)
 {
     m_alsUnitGroups.Remove(ug);
     SetModified();
 }
 public void AddUnitGroup(UnitGroup ug)
 {
     m_alsUnitGroups.Add(ug);
     SetModified();
 }
 public void RemoveUnitGroup(UnitGroup ug)
 {
     m_alsUnitGroups.Remove(ug);
     SetModified();
 }
 public void AddUnitGroup(UnitGroup ug)
 {
     m_alsUnitGroups.Add(ug);
     SetModified();
 }