4 лаба Кувшинов ПИбд-21 Простая #7
@ -113,12 +113,12 @@ namespace Laba1Loco
|
||||
/// Проход по списку
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<T> GetTrains(int? maxCars = null)
|
||||
public IEnumerable<T> GetTrains(int? maxTrains = null)
|
||||
{
|
||||
for (int i = 0; i < _places.Count; ++i)
|
||||
{
|
||||
yield return _places[i];
|
||||
if (maxCars.HasValue && i == maxCars.Value)
|
||||
if (maxTrains.HasValue && i == maxTrains.Value)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
@ -120,15 +120,15 @@ where U : IMoveableObject
|
||||
private void DrawObjects(Graphics g)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var car in _collection.GetTrains())
|
||||
foreach (var train in _collection.GetTrains())
|
||||
{
|
||||
if (car != null)
|
||||
if (train != null)
|
||||
{
|
||||
car.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
||||
if (car is DrawingLoco)
|
||||
(car as DrawingLoco).DrawTransport(g);
|
||||
train.SetPosition((i % (_pictureWidth / _placeSizeWidth)) * _placeSizeWidth, (i / (_pictureWidth / _placeSizeWidth)) * _placeSizeHeight);
|
||||
if (train is DrawingLoco)
|
||||
(train as DrawingLoco).DrawTransport(g);
|
||||
else
|
||||
car.DrawTransport(g);
|
||||
train.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user