From bf7cfe1f844e4ed352c9ab725e668f4de480af8b Mon Sep 17 00:00:00 2001
From: nezui1 <104579567+nezui1@users.noreply.github.com>
Date: Tue, 19 Mar 2024 18:02:35 +0400
Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BB=D0=BB=D0=B5=D0=BA=D1=86?=
=?UTF-8?q?=D0=B8=D1=8F=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=BA=D1=82=D0=BE=D0=B2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Drawning/DrawningWarPlane.cs | 99 +++++++++++++++----
1 file changed, 81 insertions(+), 18 deletions(-)
diff --git a/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
index 23ec6f1..ca6ebe9 100644
--- a/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
+++ b/ProjectAirFighter/ProjectAirFighter/Drawning/DrawningWarPlane.cs
@@ -76,7 +76,7 @@ public class DrawningWarPlane
/// Вес
/// Основной цвет
public DrawningWarPlane(int speed, double weight, Color bodyColor) : this()
- {
+ public void Init(EntityAirFighter entityAirFighter)
EntityWarPlane = new EntityWarPlane(speed, weight, bodyColor);
}
@@ -90,7 +90,9 @@ public class DrawningWarPlane
_drawningWarPlaneWidth = drawningWarPlaneWidth;
_drawningWarPlaneHeight = drawningWarPlaneHeight;
- }
+ _startPosY = null;
+
+
///
@@ -98,7 +100,9 @@ public class DrawningWarPlane
///
/// Ширина поля
/// Высота поля
- ///
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+
+
public bool SetPictureSize(int width, int height)
{
if (width > _drawningWarPlaneWidth && height > _drawningWarPlaneHeight)
@@ -131,8 +135,12 @@ public class DrawningWarPlane
}
+
+
+
+
///
- /// Установка позиции
+ /// Установка позиции
///
/// Координата X
/// Координата Y
@@ -166,25 +174,23 @@ public class DrawningWarPlane
}
-
-
-
///
/// Изменение направления перемещения
///
/// Направление
- /// true - перемещение выполнено, false - перемещение невозможно
+ /// true - перемещене выполнено, false - перемещение невозможно
public bool MoveTransport(DirectionType direction)
{
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return false;
}
+
switch (direction)
{
- //влево
- case DirectionType.Left:
if (_startPosX.Value - EntityWarPlane.Step > 0)
+ if (_startPosX.Value - EntityAirFighter.Step > 0)
+ if (_startPosX.Value - EntityAirFighter.Step > 0)
{
_startPosX -= (int)EntityWarPlane.Step;
}
@@ -196,13 +202,22 @@ public class DrawningWarPlane
_startPosY -= (int)EntityWarPlane.Step;
}
return true;
- //вниз
- case DirectionType.Down:
- if (_startPosY.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureHeight)
+ // вправо
+ case DirectionType.Right:
+ //TODO прописать логику сдвига в право
+
+ if (_startPosX.Value + _drawningAirFlighterWidth + EntityAirFighter.Step < _pictureWidth)
{
- _startPosY += (int)EntityWarPlane.Step;
+
+ _startPosX += (int)EntityAirFighter.Step;
+
}
return true;
+ if (_startPosY.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureHeight)
+ if (_startPosY.Value + EntityAirFighter.Step + _drawningAirFlighterHeight < _pictureHeight)
+ if (_startPosY.Value + EntityAirFighter.Step + _drawningAirFlighterHeight < _pictureHeight)
+ {
+ _startPosY += (int)EntityWarPlane.Step;
//вправо
case DirectionType.Right:
if (_startPosX.Value + EntityWarPlane.Step + _drawningWarPlaneWidth < _pictureWidth)
@@ -210,18 +225,55 @@ public class DrawningWarPlane
_startPosX += (int)EntityWarPlane.Step;
}
return true;
+ return true;
+ return true;
default:
return false;
}
}
+
+
+
+ public static GraphicsPath RoundedRect(Graphics g, Rectangle bounds, int radius)
+ {
+ int diameter = radius * 2;
+ Size size = new Size(diameter, diameter);
+ Rectangle arc = new Rectangle(bounds.Location, size);
+ GraphicsPath path = new GraphicsPath();
+
+ if (radius == 0)
+ {
+ path.AddRectangle(bounds);
+ return path;
+ }
+
+ // top left arc
+ path.AddArc(arc, 180, 90);
+
+ // top right arc
+ arc.X = bounds.Right - diameter;
+ path.AddArc(arc, 270, 90);
+
+ // bottom right arc
+ arc.Y = bounds.Bottom - diameter;
+ path.AddArc(arc, 0, 90);
+
+ // bottom left arc
+ arc.X = bounds.Left;
+ path.AddArc(arc, 90, 90);
+
+ g.FillPath(Brushes.Black, path);
+
+ path.CloseFigure();
+ return path;
public virtual void DrawTransport(Graphics g)
+ public void DrawTransport(Graphics g)
+ public void DrawTransport(Graphics g)
{
if (EntityWarPlane == null || !_startPosX.HasValue || !_startPosY.HasValue)
{
return;
- }
-
Pen pen = new(Color.Black, 3);
Pen pen_rocket = new(Color.Black);
@@ -253,7 +305,7 @@ public class DrawningWarPlane
//залив носа
Brush brBlack = new SolidBrush(Color.Black);
g.FillPolygon(brBlack, body);
-
+ g.FillPolygon(brBlack, body);
//залив корпуса
Brush br = new SolidBrush(EntityWarPlane.BodyColor);
g.FillRectangle(br, _startPosX.Value, _startPosY.Value + 60, 100, 20);
@@ -262,7 +314,18 @@ public class DrawningWarPlane
g.FillPolygon(br, wingUpper);
g.FillPolygon(br, rearWingUpper);
g.FillPolygon(br, rearWingLower);
-
+ g.FillPolygon(br, rearWingLower);
}
+
+ g.FillPolygon(brAdd, AddWingUpper);
+ g.FillPolygon(brAdd, AddWingLower);
+ }
+ }
+
+ g.FillPolygon(brAdd, AddWingUpper);
+ g.FillPolygon(brAdd, AddWingLower);
+ }
+ }
}
+