55 lines
2.0 KiB
C#
55 lines
2.0 KiB
C#
|
using AntiAircraftGun.CollectionGenereticObject;
|
|||
|
using AntiAircraftGun.Drawnings;
|
|||
|
|
|||
|
|
|||
|
namespace AntiAircraftGun.CollectionGenereticObjects;
|
|||
|
/// <summary>
|
|||
|
/// Реализация абстрактной компании - база бронемашин
|
|||
|
/// </summary>
|
|||
|
public class CarBase : AbstractCompany
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// Конструктор
|
|||
|
/// </summary>
|
|||
|
/// <param name="picWidth"></param>
|
|||
|
/// <param name="picHeight"></param>
|
|||
|
/// <param name="collection"></param>
|
|||
|
public CarBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningArmoredCar> collection) : base(picWidth, picHeight, collection)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
protected override void DrawBackgound(Graphics g)
|
|||
|
{
|
|||
|
Pen pen = new(Color.Black);
|
|||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|||
|
{
|
|||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
|||
|
{
|
|||
|
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * j));
|
|||
|
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * j), new(_placeSizeWidth * i, _placeSizeHeight * (j + 1)));
|
|||
|
}
|
|||
|
g.DrawLine(pen, new(_placeSizeWidth * i, _placeSizeHeight * (_pictureHeight / _placeSizeHeight)), new((int)(_placeSizeWidth * (i + 0.5f)), _placeSizeHeight * (_pictureHeight / _placeSizeHeight)));
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected override void SetObjectsPosition()
|
|||
|
{
|
|||
|
int n = 0;
|
|||
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|||
|
{
|
|||
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
|
|||
|
{
|
|||
|
DrawningArmoredCar? drawingTrans = _collection?.Get(n);
|
|||
|
n++;
|
|||
|
if (drawingTrans != null)
|
|||
|
{
|
|||
|
drawingTrans.SetPictureSize(_pictureWidth, _pictureHeight);
|
|||
|
drawingTrans.SetPosition(i * _placeSizeWidth + 5, j * _placeSizeHeight + 5);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|