56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using ProjectTank.Drawnings;
|
|
|
|
namespace ProjectTank.CollectionGenericObjects
|
|
{
|
|
public class TankBase : AbstractCompany
|
|
{
|
|
public TankBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTank2> collection) : base(picWidth, picHeight, collection)
|
|
{
|
|
|
|
}
|
|
protected override void DrawBackgound(Graphics g)
|
|
{
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
Pen pen = new(Color.Black, 2);
|
|
for (int i = 0; i < width + 1; i++)
|
|
{
|
|
for (int j = 0; j < height + 1; ++j)
|
|
{
|
|
g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5 + _placeSizeWidth - 45, j * _placeSizeHeight);
|
|
g.DrawLine(pen, i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + 5, j * _placeSizeHeight - _placeSizeHeight);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected override void SetObjectsPosition()
|
|
{
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
|
|
int TankWidth = 0;
|
|
int TankHeight = 0;
|
|
|
|
for (int i = 0; i < (_collection?.Count ?? 0); i++)
|
|
{
|
|
if (_collection?.Get(i) != null)
|
|
{
|
|
_collection.Get(i)?.SetPictureSize(_pictureWidth, _pictureHeight);
|
|
_collection.Get(i)?.SetPosition(_placeSizeWidth * TankWidth + 20, TankHeight * _placeSizeHeight + 5);
|
|
}
|
|
|
|
if (TankWidth < width)
|
|
TankWidth++;
|
|
else
|
|
{
|
|
TankWidth = 0;
|
|
TankHeight++;
|
|
}
|
|
if (TankHeight > height - 1)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |