using AntiAircraftGun.CollectionGenereticObject;
using AntiAircraftGun.Drawnings;
namespace AntiAircraftGun.CollectionGenereticObjects;
///
/// Реализация абстрактной компании - база бронемашин
///
public class CarBase : AbstractCompany
{
///
/// Конструктор
///
///
///
///
public CarBase(int picWidth, int picHeight, ICollectionGenericObjects collection) : base(picWidth, picHeight, collection)
{
}
///
/// Отрисовка базы
///
/// Графика
protected override void DrawBackgound(Graphics g)
{
Pen pen = new Pen(Color.Black, 4f);
for (int i = 0; i < _pictureHeight / _placeSizeHeight / 2; i++)
{
g.DrawLine(pen, 0, i * _placeSizeHeight * 2, _pictureWidth / _placeSizeWidth * _placeSizeWidth, i * _placeSizeHeight * 2);
for (int j = 0; j < _pictureWidth / _placeSizeWidth + 1; ++j)
{
g.DrawLine(pen, j * _placeSizeWidth, i * _placeSizeHeight * 2, j * _placeSizeWidth, i * _placeSizeHeight * 2 + _placeSizeHeight);
}
}
}
///
/// Установка объекта в базу
///
protected override void SetObjectsPosition()
{
int nowWidth = 0;
int nowHeight = 0;
for (int i = 0; i < (_collection?.Count ?? 0); i++)
{
if (nowHeight > _pictureHeight / _placeSizeHeight)
{
return;
}
if (_collection?.Get(i) != null)
{
_collection?.Get(i)?.SetPictureSize(_pictureWidth , _pictureHeight);
_collection?.Get(i)?.SetPosition(_placeSizeWidth * nowWidth + 10, nowHeight * _placeSizeHeight * 2 );
}
if (nowWidth < _pictureWidth / _placeSizeWidth - 1) nowWidth++;
else
{
nowWidth = 0;
nowHeight++;
}
}
}
}