public void CreateUnit(int countUnitsAttacks, int countUnitsDefense, int countUnitsSpeed) { if (countUnitsAttacks > 0 && barracks.CheckPesourcesForCreateUnit(playerResources, countUnitsAttacks)) { for (int i = 0; i < countUnitsAttacks; i++) { unitAttacks.Add(barracks.CreateUnit(new UnitAttackFactory())); } barracks.BuyUnits(playerResources, countUnitsAttacks); } if (countUnitsDefense > 0 && barracks.CheckPesourcesForCreateUnit(playerResources, countUnitsDefense)) { for (int i = 0; i < countUnitsDefense; i++) { unitDefense.Add(barracks.CreateUnit(new UnitDefenseFactory())); } barracks.BuyUnits(playerResources, countUnitsDefense); } if (countUnitsSpeed > 0 && barracks.CheckPesourcesForCreateUnit(playerResources, countUnitsSpeed)) { for (int i = 0; i < countUnitsSpeed; i++) { unitSpeed.Add(barracks.CreateUnit(new UnitSpeedFactory())); } barracks.BuyUnits(playerResources, countUnitsSpeed); } ChangingUnitsSpot.Invoke(); ChangingUnitsCountEvent.Invoke(); }