diff --git a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs
index 85ef58d..5b24d56 100644
--- a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs
+++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningAirPlane.cs
@@ -18,7 +18,7 @@ public class DrawningAirPlane : DrawningPlane
/// Признак наличия обвеса
/// Признак наличия антикрыла
/// Признак наличия гоночной полосы
- public DrawningAirPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool dopBak, bool chassi) : base(190, 70)
+ public DrawningAirPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool dopBak, bool chassi) : base(195, 70)
{
EntityPlane = new EntityAirPlane(speed, weight, bodyColor, additionalColor, radar, dopBak, chassi);
@@ -46,19 +46,21 @@ public class DrawningAirPlane : DrawningPlane
}
- _startPosX += 0;
- _startPosY += 0;
+
base.DrawTransport(g);
- _startPosX -= 0;
- _startPosY -= 0;
+
+
if (airPlane.DopBak)
{
//бак
g.FillEllipse(additionalBrush, _startPosX.Value, _startPosY.Value + 45, 40, 20);
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 40, 20);
+
}
-
+
+ if (airPlane.Radar)
+ {
//радар
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 25, _startPosX.Value + 60, _startPosY.Value + 15);
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 15, _startPosX.Value + 67, _startPosY.Value + 11);
@@ -73,10 +75,9 @@ public class DrawningAirPlane : DrawningPlane
};
g.FillPolygon(additionalBrush, curvePoints3);
+ }
-
}
}
-
-
\ No newline at end of file
+
diff --git a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs
index 1bc812b..ffcadd5 100644
--- a/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs
+++ b/ProjectAirPlane/ProjectAirPlane/Drawnings/DrawningPlane.cs
@@ -32,7 +32,7 @@ public class DrawningPlane
///
/// Ширина прорисовки самолёта
///
- private readonly int _drawningAirPlaneWidth = 190;
+ private readonly int _drawningAirPlaneWidth = 195;
///
/// Высота прорисовки самолёта
@@ -79,7 +79,7 @@ public class DrawningPlane
public DrawningPlane(int speed, double weight, Color bodyColor) : this()
{
-
+
EntityPlane = new EntityPlane(speed, weight, bodyColor);
}
@@ -91,10 +91,10 @@ public class DrawningPlane
/// Высота прорисовки самолёта
- protected DrawningPlane(int drawningAirPlaneWidth, int drawningAirPlaneHeight) : this()
+ protected DrawningPlane(int drawningPlaneWidth, int drawningPlaneHeight) : this()
{
- _drawningAirPlaneWidth = drawningAirPlaneWidth;
- _drawningAirPlaneHeight = drawningAirPlaneHeight;
+ _drawningAirPlaneWidth = drawningPlaneWidth;
+ _drawningAirPlaneHeight = drawningPlaneHeight;
}
@@ -109,9 +109,26 @@ public class DrawningPlane
{
// TODO проверка, что объект "влезает" в размеры поля
- // если влезает, сохраняем границы и корректируем позицию объекта, если она была уже установлена
+ if (_drawningAirPlaneWidth > width || _drawningAirPlaneHeight > height)
+ {
+ return false;
+ }
+
_pictureWidth = width;
_pictureHeight = height;
+ if (_startPosX.HasValue || _startPosY.HasValue)
+ {
+ if (_startPosX + _drawningAirPlaneWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _drawningAirPlaneWidth;
+ }
+ else if (_startPosX < 0) _startPosX = 0;
+ if (_startPosY + _drawningAirPlaneHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _drawningAirPlaneHeight;
+ }
+ else if (_startPosY < 0) _startPosY = 0;
+ }
return true;
}
@@ -203,6 +220,13 @@ public class DrawningPlane
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(EntityPlane.BodyColor);
+
+ //шасси
+ g.DrawLine(pen, _startPosX.Value + 50, _startPosY.Value + 55, _startPosX.Value + 50, _startPosY.Value + 70);
+ g.DrawLine(pen, _startPosX.Value + 150, _startPosY.Value + 55, _startPosX.Value + 150, _startPosY.Value + 70);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 40, _startPosY.Value + 65, 10, 10);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 65, 10, 10);
+ g.FillEllipse(additionalBrush, _startPosX.Value + 145, _startPosY.Value + 65, 10, 10);
// корпус
Brush br = new SolidBrush(EntityPlane.BodyColor);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 25, 170, 30);
diff --git a/ProjectAirPlane/ProjectAirPlane/FormAirPlane.Designer.cs b/ProjectAirPlane/ProjectAirPlane/FormAirPlane.Designer.cs
index 6a010fa..aecfeea 100644
--- a/ProjectAirPlane/ProjectAirPlane/FormAirPlane.Designer.cs
+++ b/ProjectAirPlane/ProjectAirPlane/FormAirPlane.Designer.cs
@@ -118,6 +118,7 @@
ButtonCreatePlane.TabIndex = 6;
ButtonCreatePlane.Text = "Создать самолёт";
ButtonCreatePlane.UseVisualStyleBackColor = true;
+ ButtonCreatePlane.Click += ButtonCreatePlane_Click;
//
// comboBoxStrategy
//
@@ -137,7 +138,7 @@
buttonStrategyStepS.TabIndex = 8;
buttonStrategyStepS.Text = "Шаг";
buttonStrategyStepS.UseVisualStyleBackColor = true;
- buttonStrategyStepS.Click += buttonStrategyStepS_Click;
+ buttonStrategyStepS.Click += ButtonStrategyStep_Click;
//
// FormAirPlane
//
diff --git a/ProjectAirPlane/ProjectAirPlane/FormAirPlane.cs b/ProjectAirPlane/ProjectAirPlane/FormAirPlane.cs
index 9620e4b..355bcff 100644
--- a/ProjectAirPlane/ProjectAirPlane/FormAirPlane.cs
+++ b/ProjectAirPlane/ProjectAirPlane/FormAirPlane.cs
@@ -1,6 +1,7 @@
using ProjectAirPlane.Drawnings;
using ProjectAirPlane.MovementStrategy;
+
namespace ProjectAirPlane;
///
@@ -130,12 +131,9 @@ public partial class FormAirPlane : Form
///
///
///
- private void buttonStrategyStepS_Click(object sender, EventArgs e)
+ private void ButtonStrategyStep_Click(object sender, EventArgs e)
{
- if (_drawningPlane == null)
- {
- return;
- }
+ if (_drawningPlane == null) return;
if (comboBoxStrategy.Enabled)
{
@@ -149,7 +147,7 @@ public partial class FormAirPlane : Form
{
return;
}
- _strategy.SetData(new MoveablePlane(_drawningPlane), pictureBoxAirPlane.Height, pictureBoxAirPlane.Width);
+ _strategy.SetData(new MoveablePlane(_drawningPlane), pictureBoxAirPlane.Width, pictureBoxAirPlane.Height);
}
if (_strategy == null)
@@ -167,4 +165,6 @@ public partial class FormAirPlane : Form
_strategy = null;
}
}
+
+
}
\ No newline at end of file
diff --git a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/IMoveableObject.cs b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/IMoveableObject.cs
index 3619424..51bec7c 100644
--- a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/IMoveableObject.cs
+++ b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/IMoveableObject.cs
@@ -21,4 +21,6 @@ public interface IMoveableObject
/// Направление
/// true - объект перемещен, false - перемещение невозможно
bool TryMoveObject(MovementDirection direction);
+
+ protected void Move();
}
\ No newline at end of file
diff --git a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveToCenter.cs b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveToCenter.cs
index 14c1e41..f2dfc0d 100644
--- a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveToCenter.cs
+++ b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveToCenter.cs
@@ -1,5 +1,5 @@
-namespace ProjectAirPlane.MovementStrategy;
-
+
+namespace ProjectAirPlane.MovementStrategy;
///
/// Стратегия перемещения объекта в центр экрана
@@ -13,11 +13,9 @@ public class MoveToCenter : AbstractStrategy
{
return false;
}
-
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 && objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
- objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
+ objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 && objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2;
}
-
protected override void MoveToTarget()
{
ObjectParameters? objParams = GetObjectParameters;
@@ -25,7 +23,6 @@ public class MoveToCenter : AbstractStrategy
{
return;
}
-
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
if (Math.Abs(diffX) > GetStep())
{
@@ -38,7 +35,6 @@ public class MoveToCenter : AbstractStrategy
MoveRight();
}
}
-
int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
if (Math.Abs(diffY) > GetStep())
{
@@ -53,3 +49,4 @@ public class MoveToCenter : AbstractStrategy
}
}
}
+
diff --git a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveablePlane.cs b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveablePlane.cs
index 4bc85a1..343743b 100644
--- a/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveablePlane.cs
+++ b/ProjectAirPlane/ProjectAirPlane/MovementStrategy/MoveablePlane.cs
@@ -58,4 +58,9 @@ public class MoveablePlane : IMoveableObject
_ => DirectionType.Unknow,
};
}
+
+ void IMoveableObject.Move()
+ {
+ throw new NotImplementedException();
+ }
}