Продвинутый объект
This commit is contained in:
parent
01cffb5f90
commit
098ef0c921
@ -33,9 +33,67 @@ namespace AircraftCarrier
|
|||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush dopBrush = new SolidBrush(aircraftCarrier.DopColor);
|
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);
|
||||||
|
|
||||||
|
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);
|
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>
|
||||||
/// Левая координата отрисовки военного корабля
|
/// Левая координата отрисовки военного корабля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float _startPosX;
|
protected float _startPosX;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя кооридната отрисовки военного корабля
|
/// Верхняя кооридната отрисовки военного корабля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private float _startPosY;
|
protected float _startPosY;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна отрисовки
|
/// Ширина окна отрисовки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -72,28 +72,15 @@ namespace AircraftCarrier
|
|||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <param name="height"></param>
|
/// <param name="height"></param>
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (width >= x + _warshipWidth && height >= y + _warshipHeight && x >= 0 && y >= 0)
|
||||||
{
|
{
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
|
|
||||||
if (width < _warshipWidth)
|
|
||||||
{
|
|
||||||
width = _warshipWidth;
|
|
||||||
}
|
|
||||||
if (height < _warshipHeight)
|
|
||||||
{
|
|
||||||
height = _warshipHeight;
|
|
||||||
}
|
|
||||||
if(x + _warshipWidth > width)
|
|
||||||
{
|
|
||||||
_startPosX -= x + _warshipWidth - width;
|
|
||||||
}
|
|
||||||
if (y + _warshipHeight > height)
|
|
||||||
{
|
|
||||||
_pictureHeight -= y + _warshipHeight - height;
|
|
||||||
}
|
}
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Изменение направления пермещения
|
/// Изменение направления пермещения
|
||||||
@ -116,14 +103,14 @@ namespace AircraftCarrier
|
|||||||
break;
|
break;
|
||||||
//влево
|
//влево
|
||||||
case Direction.Left:
|
case Direction.Left:
|
||||||
if(_startPosX - Warship.Step > 0)
|
if(_startPosX - Warship.Step >= 0)
|
||||||
{
|
{
|
||||||
_startPosX -= Warship.Step;
|
_startPosX -= Warship.Step;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
//вверх
|
//вверх
|
||||||
case Direction.Up:
|
case Direction.Up:
|
||||||
if (_startPosY - Warship.Step > 0)
|
if (_startPosY - Warship.Step >= 0)
|
||||||
{
|
{
|
||||||
_startPosY -= Warship.Step;
|
_startPosY -= Warship.Step;
|
||||||
}
|
}
|
||||||
@ -150,34 +137,33 @@ namespace AircraftCarrier
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
|
Brush brOrange = new SolidBrush(Color.Orange);
|
||||||
//границы военного корабля
|
Brush brPurple = new SolidBrush(Color.RebeccaPurple);
|
||||||
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 br = new SolidBrush(Warship?.BodyColor ?? Color.White);
|
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);
|
||||||
|
|
||||||
|
PointF[] PointsWarship =
|
||||||
|
{
|
||||||
|
pointWarship1, pointWarship2, pointWarship3, pointWarship4, pointWarship5
|
||||||
|
};
|
||||||
|
g.FillPolygon(br, PointsWarship);
|
||||||
|
g.DrawPolygon(pen, PointsWarship);
|
||||||
|
|
||||||
//мачта
|
//мачта
|
||||||
Brush brWhite = new SolidBrush(Color.White);
|
g.FillEllipse(brOrange, _startPosX + 79, _startPosY + 13, 15, 15);
|
||||||
g.FillEllipse(brWhite, _startPosX + 79, _startPosY + 13, 15, 15);
|
|
||||||
|
|
||||||
//границы мачты
|
//границы мачты
|
||||||
g.DrawEllipse(pen, _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(brPurple, _startPosX + 64, _startPosY + 10, 10, 20);
|
||||||
g.FillRectangle(brWhite, _startPosX + 44, _startPosY + 15, 20, 10);
|
g.FillRectangle(brPurple, _startPosX + 44, _startPosY + 15, 20, 10);
|
||||||
|
|
||||||
//границы палуба
|
//границы палуба
|
||||||
g.DrawRectangle(pen, _startPosX + 64, _startPosY + 10, 10, 20);
|
g.DrawRectangle(pen, _startPosX + 64, _startPosY + 10, 10, 20);
|
||||||
|
@ -13,17 +13,17 @@ namespace AircraftCarrier
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public Color DopColor { get; private set; }
|
public Color DopColor { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак наличия обвеса
|
/// Признак наличия боковой площадки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool BodyKit { get; private set; }
|
public bool BodyKit { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак наличия антикрыла
|
/// Признак наличия рубки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Wing { get; private set; }
|
public bool Сabin { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Признак наличия гоночной полосы
|
/// Признак наличия усиленного двигателя
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool SportLine { get; private set; }
|
public bool SuperEngine { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация свойств
|
/// Инициализация свойств
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -39,8 +39,8 @@ namespace AircraftCarrier
|
|||||||
{
|
{
|
||||||
DopColor = dopColor;
|
DopColor = dopColor;
|
||||||
BodyKit = bodyKit;
|
BodyKit = bodyKit;
|
||||||
Wing = wing;
|
Сabin = wing;
|
||||||
SportLine = sportLine;
|
SuperEngine = sportLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user