63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
using ProjectAirFighter.CollectionGenericObject;
|
|
using ProjectAirFighter.Drawning;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectAirFighter.CollectionGenericObjects;
|
|
|
|
public class WarPlaneBase : AbstractCompany
|
|
{
|
|
public WarPlaneBase(int picWidth, int picHeight, ICollectionGenericObjects<DrawningWarPlane> collection) : base(picWidth, picHeight, collection)
|
|
{
|
|
}
|
|
|
|
protected override void DrawBackgound(Graphics g)
|
|
{
|
|
Pen pen = new(Color.Black, 3);
|
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
|
{
|
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; j++)
|
|
{
|
|
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth - 20, j * _placeSizeHeight);
|
|
}
|
|
g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);
|
|
}
|
|
}
|
|
|
|
protected override void SetObjectsPosition()
|
|
{
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
|
|
int curWidth = width - 1;
|
|
int curHeight = height - 1;
|
|
|
|
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 * curWidth + 10, curHeight * _placeSizeHeight + 5);
|
|
}
|
|
|
|
if (curWidth > 0)
|
|
curWidth--;
|
|
else
|
|
{
|
|
curHeight--;
|
|
curWidth = width - 1;
|
|
}
|
|
if (curHeight < 0)
|
|
{
|
|
return;
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|