Пример #1
0
 public void Clear()
 {
     if (UnitGroups == null)
     {
         UnitGroups = new HashSet <UnitListObject>();
     }
     else
     {
         UnitGroups.Clear();
     }
 }
Пример #2
0
        public UnitGroup GetUnitGroup(string name)
        {
            if (UnitGroups == null)
            {
                throw new InvalidOperationException("The data must be loaded before getting a unit group.");
            }

            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            return(UnitGroups.ContainsKey(name) ? UnitGroups[name] : UnitGroup.Unknown);
        }
Пример #3
0
        public Unit SelectNextUnitGroup()
        {
            var ret = UnitGroups
                      .Where(p => !p.HasMoved)
                      .Where(p => p.IsAnyAlive)
                      .Where(p => p.IsBattle)
                      .OrderBy(p => p.Weight)
                      .FirstOrDefault();

            if (ret != null)
            {
                ret.HasMoved = true;
            }
            return(ret);
        }
Пример #4
0
        private Unit GetUnit(string unitGroupId, string unitId)
        {
            var unitGroup = UnitGroups
                            .FirstOrDefault(ug => ug.GroupIdentifier == unitGroupId);

            if (unitGroup == null)
            {
                throw new ExpectedException($"'{unitGroupId}' is not a known unit group.");
            }

            var unit = unitGroup
                       .Units
                       .FirstOrDefault(u => u.UnitIdentifier == unitId);

            if (unit == null)
            {
                throw new ExpectedException($"'{unitId}' is not part of the '{unitGroup.GroupIdentifier}' unit group.");
            }

            return(unit);
        }
Пример #5
0
        public void Clear()
        {
            ClearRename();

            if (UnitGroups == null)
            {
                UnitGroups = new HashSet <UnitListObject>();
            }
            else
            {
                foreach (UnitListObject ulo in UnitGroups)
                {
                    if (ulo != null)
                    {
                        Destroy(ulo.gameObject);
                    }
                }

                UnitGroups.Clear();
            }

            SelectedGroups.Clear();
        }
Пример #6
0
 public static UnitGroup GetUnitGroup(this UnitGroups source, string id)
 {
     return(source.FirstOrDefault(l => l.Id == id));
 }
Пример #7
0
 public void ResetArmor()
 {
     UnitGroups.ForEach(p => p.ResetArmor());
 }
Пример #8
0
 public void ResetMoved()
 {
     UnitGroups.ForEach(p => p.ResetMoved());
 }
Пример #9
0
 public string InfectionUnitAmount()
 {
     return(UnitGroups.Where(c => !c.GameOver() && c.UnitType == UnitType.Infection).Sum(c => c.AmountUnits()).ToString());
 }
Пример #10
0
 public string ImmuneUnitsAmount()
 {
     return(UnitGroups.Where(c => !c.GameOver() && c.UnitType == UnitType.Immune_System).Sum(c => c.AmountUnits()).ToString());
 }
Пример #11
0
 public string Part1()
 {
     return(UnitGroups.Sum(c => c.AmountUnits()).ToString());
 }