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;
 }
예제 #2
0
 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;
 }
예제 #3
0
 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;
 }
예제 #4
0
 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");
     }
 }