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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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");
     }
 }