LabWork02 #3
@ -33,9 +33,67 @@ namespace AircraftCarrier
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush dopBrush = new SolidBrush(aircraftCarrier.DopColor);
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
Brush brRed = new SolidBrush(Color.Red);
|
||||
Brush br = new SolidBrush(Warship?.BodyColor ?? Color.White);
|
||||
|
||||
if (aircraftCarrier.BodyKit)
|
||||
{
|
||||
//боковая площадка
|
||||
PointF pointAircraftCarrier1 = new PointF(_startPosX + 94, _startPosY + 40);
|
||||
PointF pointAircraftCarrier2 = new PointF(_startPosX + 74, _startPosY + 60);
|
||||
PointF pointAircraftCarrier3 = new PointF(_startPosX + 24, _startPosY + 60);
|
||||
PointF pointAircraftCarrier4 = new PointF(_startPosX + 4, _startPosY + 40);
|
||||
|
||||
base.DrawTransport(g);
|
||||
PointF[] PointsAircraftCarrier =
|
||||
{
|
||||
pointAircraftCarrier1, pointAircraftCarrier2, pointAircraftCarrier3, pointAircraftCarrier4
|
||||
};
|
||||
g.FillPolygon(br, PointsAircraftCarrier);
|
||||
g.DrawPolygon(pen, PointsAircraftCarrier);
|
||||
|
||||
//полоса
|
||||
PointF pontStartLine1 = new PointF(_startPosX + 4, _startPosY);
|
||||
PointF pontStartLine2 = new PointF(_startPosX + 15, _startPosY);
|
||||
PointF pontStartLine3 = new PointF(_startPosX + 74, _startPosY + 60);
|
||||
PointF pontStartLine4 = new PointF(_startPosX + 59, _startPosY + 60);
|
||||
|
||||
PointF[] PointsStartLine =
|
||||
{
|
||||
pontStartLine1, pontStartLine2, pontStartLine3, pontStartLine4
|
||||
};
|
||||
g.FillPolygon(brGray, PointsStartLine);
|
||||
g.DrawPolygon(pen, PointsStartLine);
|
||||
}
|
||||
|
||||
if (aircraftCarrier.SuperEngine)
|
||||
{
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 10, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 10, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 18, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 18, 10, 10);
|
||||
|
||||
g.FillEllipse(brRed, _startPosX, _startPosY + 30, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX, _startPosY + 30, 10, 10);
|
||||
}
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
if (aircraftCarrier.Сabin)
|
||||
{
|
||||
g.FillEllipse(brGray, _startPosX + 10, _startPosY + 15, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX + 10, _startPosY + 15, 10, 10);
|
||||
|
||||
g.FillEllipse(brGray, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
g.DrawEllipse(pen, _startPosX + 20, _startPosY + 15, 10, 10);
|
||||
|
||||
g.FillRectangle(brGray, _startPosX + 15, _startPosY + 15, 10, 10);
|
||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY + 15, 10, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,11 +18,11 @@ namespace AircraftCarrier
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки военного корабля
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки военного корабля
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -73,27 +73,14 @@ namespace AircraftCarrier
|
||||
/// <param name="height"></param>
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
|
||||
if (width < _warshipWidth)
|
||||
if (width >= x + _warshipWidth && height >= y + _warshipHeight && x >= 0 && y >= 0)
|
||||
{
|
||||
width = _warshipWidth;
|
||||
}
|
||||
if (height < _warshipHeight)
|
||||
{
|
||||
height = _warshipHeight;
|
||||
}
|
||||
if(x + _warshipWidth > width)
|
||||
{
|
||||
_startPosX -= x + _warshipWidth - width;
|
||||
}
|
||||
if (y + _warshipHeight > height)
|
||||
{
|
||||
_pictureHeight -= y + _warshipHeight - height;
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
else return;
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
@ -116,14 +103,14 @@ namespace AircraftCarrier
|
||||
break;
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if(_startPosX - Warship.Step > 0)
|
||||
if(_startPosX - Warship.Step >= 0)
|
||||
{
|
||||
_startPosX -= Warship.Step;
|
||||
}
|
||||
break;
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
if (_startPosY - Warship.Step > 0)
|
||||
if (_startPosY - Warship.Step >= 0)
|
||||
{
|
||||
_startPosY -= Warship.Step;
|
||||
}
|
||||
@ -150,34 +137,33 @@ namespace AircraftCarrier
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
//границы военного корабля
|
||||
PointF point1 = new PointF(_startPosX + 4, _startPosY);
|
||||
PointF point2 = new PointF(_startPosX + 94, _startPosY);
|
||||
PointF point3 = new PointF(_startPosX + 114, _startPosY + 20);
|
||||
PointF point4 = new PointF(_startPosX + 94, _startPosY + 40);
|
||||
PointF point5 = new PointF(_startPosX + 4, _startPosY + 40);
|
||||
|
||||
PointF[] curvePoints =
|
||||
{
|
||||
point1, point2, point3, point4, point5
|
||||
};
|
||||
g.DrawPolygon(pen, curvePoints);
|
||||
Brush brOrange = new SolidBrush(Color.Orange);
|
||||
Brush brPurple = new SolidBrush(Color.RebeccaPurple);
|
||||
|
||||
//главная палуба
|
||||
Brush br = new SolidBrush(Warship?.BodyColor ?? Color.White);
|
||||
g.FillPolygon(br, curvePoints);
|
||||
PointF pointWarship1 = new PointF(_startPosX + 4, _startPosY);
|
||||
PointF pointWarship2 = new PointF(_startPosX + 94, _startPosY);
|
||||
PointF pointWarship3 = new PointF(_startPosX + 114, _startPosY + 20);
|
||||
PointF pointWarship4 = new PointF(_startPosX + 94, _startPosY + 40);
|
||||
PointF pointWarship5 = new PointF(_startPosX + 4, _startPosY + 40);
|
||||
|
||||
//мачта
|
||||
Brush brWhite = new SolidBrush(Color.White);
|
||||
g.FillEllipse(brWhite, _startPosX + 79, _startPosY + 13, 15, 15);
|
||||
PointF[] PointsWarship =
|
||||
{
|
||||
pointWarship1, pointWarship2, pointWarship3, pointWarship4, pointWarship5
|
||||
};
|
||||
g.FillPolygon(br, PointsWarship);
|
||||
g.DrawPolygon(pen, PointsWarship);
|
||||
|
||||
//мачта
|
||||
g.FillEllipse(brOrange, _startPosX + 79, _startPosY + 13, 15, 15);
|
||||
|
||||
//границы мачты
|
||||
g.DrawEllipse(pen, _startPosX + 79, _startPosY + 13, 15, 15);
|
||||
|
||||
//палуба
|
||||
g.FillRectangle(brWhite, _startPosX + 64, _startPosY + 10, 10, 20);
|
||||
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 15, 20, 10);
|
||||
//палуба
|
||||
g.FillRectangle(brPurple, _startPosX + 64, _startPosY + 10, 10, 20);
|
||||
g.FillRectangle(brPurple, _startPosX + 44, _startPosY + 15, 20, 10);
|
||||
|
||||
//границы палуба
|
||||
g.DrawRectangle(pen, _startPosX + 64, _startPosY + 10, 10, 20);
|
||||
|
@ -13,17 +13,17 @@ namespace AircraftCarrier
|
||||
/// </summary>
|
||||
public Color DopColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия обвеса
|
||||
/// Признак наличия боковой площадки
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия антикрыла
|
||||
/// Признак наличия рубки
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
public bool Сabin { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак наличия гоночной полосы
|
||||
/// Признак наличия усиленного двигателя
|
||||
/// </summary>
|
||||
public bool SportLine { get; private set; }
|
||||
public bool SuperEngine { get; private set; }
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
@ -39,8 +39,8 @@ namespace AircraftCarrier
|
||||
{
|
||||
DopColor = dopColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
SportLine = sportLine;
|
||||
Сabin = wing;
|
||||
SuperEngine = sportLine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user