private static IEnumerable<Unit> GenerateUnits(int warriorPositionX, int rangersPositionX, UnitType warriorType, UnitType rangerType)
 {
     List<Unit> units = new List<Unit>();
     for (var i = 0; i < WarriorsPositionsY.Length; i++)
     {
         var warriorUnit = UnitFactory.GetUnit(warriorType, warriorPositionX, WarriorsPositionsY[i]);
         units.Add(warriorUnit);
     }
     for (var i = 0; i < RangersPositionsY.Length; i++)
     {
         var rangerUnit = UnitFactory.GetUnit(rangerType, rangersPositionX, RangersPositionsY[i]);
         units.Add(rangerUnit);
     }
     return units;
 }
 private static Unit GetRanger(UnitType type, int x, int y)
 {
     var ranger = new Unit()
     {
         PositionX = x,
         PositionY = y,
         HitPoints = RangerHitPoints,
         Attack = RangerAttack,
         Armor = RangerArmor,
         Range = RangerRange,
         Speed = RangerSpeed,
         UnitType = type
     };
     return ranger;
 }
 private static Unit GetWarrior(UnitType type, int x, int y)
 {
     var warrior = new Unit()
     {
         PositionX = x,
         PositionY = y,
         HitPoints = WarriorHitPoints,
         Attack = WarriorAttack,
         Armor = WarriorArmor,
         Range = WarriorRange,
         Speed = WarriorSpeed,
         UnitType = type
     };
     return warrior;
 }
 public static Unit GetUnit(UnitType unitType, int x, int y)
 {
     if (unitType.Value == WarriorType)
     {
         return GetWarrior(unitType,x, y);
     }
     else if (unitType.Value == RangerType)
     {
         return GetRanger(unitType, x, y);
     }
     else
     {
         throw new ArgumentOutOfRangeException("Unit type", "No such unit type");
     }
 }