68 lines
2.0 KiB
C#
68 lines
2.0 KiB
C#
using ProjectStormTrooper.Drawnings;
|
|
using ProjectStormTrooper.Exceptions;
|
|
|
|
|
|
namespace ProjectStormTrooper.CollectionGenericObjects;
|
|
|
|
/// <summary>
|
|
/// Реализация абстрактной компании - каршеринг
|
|
/// </summary>
|
|
public class Hangar : AbstractCompany
|
|
{
|
|
|
|
/// <summary>
|
|
/// Конструктор
|
|
/// </summary>
|
|
/// <param name="picWidth"></param>
|
|
/// <param name="picHeight"></param>
|
|
/// <param name="collection"></param>
|
|
public Hangar(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection)
|
|
{
|
|
}
|
|
|
|
protected override void DrawBackgound(Graphics g)
|
|
{
|
|
Pen pen = new(Color.Black, 3);
|
|
int posX = 0;
|
|
for (int i = 0; i < _pictureWidth/_placeSizeWidth; i++)
|
|
{
|
|
int posY = 0;
|
|
g.DrawLine(pen, posX, posY, posX, posY + _placeSizeHeight*(_pictureHeight/ _placeSizeHeight));
|
|
for(int j = 0; j <= _pictureHeight/_placeSizeHeight; j++)
|
|
{
|
|
g.DrawLine(pen, posX, posY, posX + _placeSizeWidth-ColsSpace, posY);
|
|
posY += _placeSizeHeight;
|
|
}
|
|
posX += _placeSizeWidth;
|
|
}
|
|
}
|
|
|
|
protected override void SetObjectsPosition()
|
|
{
|
|
int posX = _pictureWidth / _placeSizeWidth-1;
|
|
int posY = 0;
|
|
for (int i = 0; i < _collection?.Count; i++)
|
|
{
|
|
|
|
try
|
|
{
|
|
_collection?.Get(i).SetPictureSize(_pictureWidth, _pictureHeight);
|
|
_collection?.Get(i).SetPosition(posX * _placeSizeWidth, posY * _placeSizeHeight);
|
|
}
|
|
catch (ObjectNotFoundException)
|
|
{
|
|
break;
|
|
}
|
|
if(posX > 0)
|
|
{
|
|
posX--;
|
|
}
|
|
else
|
|
{
|
|
posX = _pictureWidth / _placeSizeWidth-1;
|
|
posY++;
|
|
}
|
|
if(posY >= _placeSizeHeight) { return; }
|
|
}
|
|
}
|
|
} |