From ec08a44682cc1ed06d0b9525d8c1afadee88c82f Mon Sep 17 00:00:00 2001 From: malimova Date: Sun, 26 Nov 2023 22:01:52 +0400 Subject: [PATCH] =?UTF-8?q?=D0=92=D1=81=D1=91=20=D1=81=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D0=B0=D0=BD=D0=BE=20=D0=B2=20=D1=83=D1=81=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=BB=D0=B0=D0=B1=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/DrawningAirBomber.cs | 20 +-- AirBomber/AirBomber/DrawningAirPlane.cs | 25 ++-- AirBomber/AirBomber/DrawningEnginesCircle.cs | 94 +++++++++++++ ...Engines.cs => DrawningEnginesRectangle.cs} | 2 +- .../AirBomber/DrawningEnginesTriangle.cs | 130 ++++++++++++++++++ AirBomber/AirBomber/FormAirBomber.cs | 25 ++-- 6 files changed, 261 insertions(+), 35 deletions(-) create mode 100644 AirBomber/AirBomber/DrawningEnginesCircle.cs rename AirBomber/AirBomber/{DrawningEngines.cs => DrawningEnginesRectangle.cs} (98%) create mode 100644 AirBomber/AirBomber/DrawningEnginesTriangle.cs diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs index f92ad33..1d4e68a 100644 --- a/AirBomber/AirBomber/DrawningAirBomber.cs +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -8,8 +8,8 @@ namespace AirBomber { public class DrawningAirBomber : DrawningAirPlane { - public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height) : - base(speed, weight, bodyColor, width, height, 160, 118) + public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height, int engines, int enginesShape) : + base(speed, weight, bodyColor, width, height, engines, enginesShape) { if (EntityAirPlane != null) { @@ -26,17 +26,17 @@ namespace AirBomber Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor); base.DrawPlane(g); // bombs - g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29); - g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29); - g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29); g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15); g.DrawEllipse(pen, _startPosX + 140, _startPosY + 50, 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 30, 15, 15); + g.DrawEllipse(pen, _startPosX + 140, _startPosY + 30, 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 70, 15, 15); + g.DrawEllipse(pen, _startPosX + 140, _startPosY + 70, 15, 15); // fueltanks - g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15); - g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15); - g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15); - g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15); + g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 34, 30, 15); + g.DrawRectangle(pen, _startPosX + 85, _startPosY + 34, 30, 15); + g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 70, 30, 15); + g.DrawRectangle(pen, _startPosX + 85, _startPosY + 70, 30, 15); } } } diff --git a/AirBomber/AirBomber/DrawningAirPlane.cs b/AirBomber/AirBomber/DrawningAirPlane.cs index 455d9f6..b28b224 100644 --- a/AirBomber/AirBomber/DrawningAirPlane.cs +++ b/AirBomber/AirBomber/DrawningAirPlane.cs @@ -15,7 +15,8 @@ namespace AirBomber protected int _startPosY; protected readonly int _airPlaneWidth = 150; protected readonly int _airPlaneHeight = 118; - public DrawningAirPlane(int speed, double weight, Color bodyColor, int width, int height) + private IDrawningEngines drawningEngines; + public DrawningAirPlane(int speed, double weight, Color bodyColor, int width, int height, int engines, int enginesShape) { if (width < _airPlaneWidth || height < _airPlaneHeight) { @@ -24,18 +25,19 @@ namespace AirBomber _pictureWidth = width; _pictureHeight = height; EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor); - } - protected DrawningAirPlane(int speed, double weight, Color bodyColor, int width, int height, int airPlaneWidth, int airPlaneHeight) - { - if (width < _airPlaneWidth || height < _airPlaneHeight) + switch (enginesShape) { - return; + case 1: + drawningEngines = new DrawningEnginesCircle(); + break; + case 2: + drawningEngines = new DrawningEnginesTriangle(); + break; + default: + drawningEngines = new DrawningEnginesRectangle(); + break; } - _pictureWidth = width; - _pictureHeight = height; - _airPlaneWidth = airPlaneWidth; - _airPlaneHeight = airPlaneHeight; - EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor); + drawningEngines.SetAmount(engines); } public void SetPosition(int x, int y) { @@ -140,6 +142,7 @@ namespace AirBomber new Point(_startPosX + 140, _startPosY + 70), } ); + drawningEngines.DrawEngines(g, _startPosX, _startPosY); } public int GetPosX => _startPosX; public int GetPosY => _startPosY; diff --git a/AirBomber/AirBomber/DrawningEnginesCircle.cs b/AirBomber/AirBomber/DrawningEnginesCircle.cs new file mode 100644 index 0000000..e6ae763 --- /dev/null +++ b/AirBomber/AirBomber/DrawningEnginesCircle.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public class DrawningEnginesCircle : IDrawningEngines + { + private Engines amount; + public void SetAmount(int a) + { + if (a <= 2) + { + amount = Engines.Two; + } + else if (a == 4) + { + amount = Engines.Four; + } + else if (a >= 6) + { + amount = Engines.Six; + } + } + public void DrawEngines(Graphics g, int _startPosX, int _startPosY) + { + Brush enginesColor = new SolidBrush(Color.Black); + + g.FillPolygon(enginesColor, new Point[] //two up + { + new Point(_startPosX + 51, _startPosY + 30), + new Point(_startPosX + 75, _startPosY + 30), + new Point(_startPosX + 75, _startPosY + 40), + new Point(_startPosX + 53, _startPosY + 40), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 28, 13, 13); + g.FillPolygon(enginesColor, new Point[] //two down + { + new Point(_startPosX + 52, _startPosY + 80), + new Point(_startPosX + 75, _startPosY + 80), + new Point(_startPosX + 75, _startPosY + 90), + new Point(_startPosX + 50, _startPosY + 90), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 78, 13, 13); + + if (amount == Engines.Four || amount == Engines.Six) + { + g.FillPolygon(enginesColor, new Point[] //four up + { + new Point(_startPosX + 48, _startPosY + 18), + new Point(_startPosX + 75, _startPosY + 18), + new Point(_startPosX + 75, _startPosY + 28), + new Point(_startPosX + 50, _startPosY + 28), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 16, 13, 13); + g.FillPolygon(enginesColor, new Point[] //four down + { + new Point(_startPosX + 49, _startPosY + 92), + new Point(_startPosX + 75, _startPosY + 92), + new Point(_startPosX + 75, _startPosY + 102), + new Point(_startPosX + 47, _startPosY + 102), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 90, 13, 13); + } + if (amount == Engines.Six) + { + g.FillPolygon(enginesColor, new Point[] //six up + { + new Point(_startPosX + 46, _startPosY + 6), + new Point(_startPosX + 75, _startPosY + 6), + new Point(_startPosX + 75, _startPosY + 16), + new Point(_startPosX + 48, _startPosY + 16), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 4, 13, 13); + g.FillPolygon(enginesColor, new Point[] //six down + { + new Point(_startPosX + 47, _startPosY + 104), + new Point(_startPosX + 75, _startPosY + 104), + new Point(_startPosX + 75, _startPosY + 114), + new Point(_startPosX + 45, _startPosY + 114), + } + ); + g.FillEllipse(enginesColor, _startPosX + 71, _startPosY + 102, 13, 13); + } + } + } +} diff --git a/AirBomber/AirBomber/DrawningEngines.cs b/AirBomber/AirBomber/DrawningEnginesRectangle.cs similarity index 98% rename from AirBomber/AirBomber/DrawningEngines.cs rename to AirBomber/AirBomber/DrawningEnginesRectangle.cs index 64d97f8..8801ec8 100644 --- a/AirBomber/AirBomber/DrawningEngines.cs +++ b/AirBomber/AirBomber/DrawningEnginesRectangle.cs @@ -7,7 +7,7 @@ using System.Threading.Tasks; namespace AirBomber { - internal class DrawningEngines + public class DrawningEnginesRectangle : IDrawningEngines { private Engines amount; public void SetAmount(int a) diff --git a/AirBomber/AirBomber/DrawningEnginesTriangle.cs b/AirBomber/AirBomber/DrawningEnginesTriangle.cs new file mode 100644 index 0000000..bd6b48b --- /dev/null +++ b/AirBomber/AirBomber/DrawningEnginesTriangle.cs @@ -0,0 +1,130 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public class DrawningEnginesTriangle : IDrawningEngines + { + private Engines amount; + public void SetAmount(int a) + { + if (a <= 2) + { + amount = Engines.Two; + } + else if (a == 4) + { + amount = Engines.Four; + } + else if (a >= 6) + { + amount = Engines.Six; + } + } + public void DrawEngines(Graphics g, int _startPosX, int _startPosY) + { + Brush enginesColor = new SolidBrush(Color.Black); + + g.FillPolygon(enginesColor, new Point[] //two up + { + new Point(_startPosX + 51, _startPosY + 30), + new Point(_startPosX + 75, _startPosY + 30), + new Point(_startPosX + 75, _startPosY + 40), + new Point(_startPosX + 53, _startPosY + 40), + } + ); + g.FillPolygon(enginesColor, new Point[] //two up TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 33), + new Point(_startPosX + 80, _startPosY + 28), + new Point(_startPosX + 80, _startPosY + 41), + } + ); + g.FillPolygon(enginesColor, new Point[] //two down + { + new Point(_startPosX + 52, _startPosY + 80), + new Point(_startPosX + 75, _startPosY + 80), + new Point(_startPosX + 75, _startPosY + 90), + new Point(_startPosX + 50, _startPosY + 90), + } + ); + g.FillPolygon(enginesColor, new Point[] //two down TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 83), + new Point(_startPosX + 80, _startPosY + 78), + new Point(_startPosX + 80, _startPosY + 91), + } + ); + + if (amount == Engines.Four || amount == Engines.Six) + { + g.FillPolygon(enginesColor, new Point[] //four up + { + new Point(_startPosX + 48, _startPosY + 18), + new Point(_startPosX + 75, _startPosY + 18), + new Point(_startPosX + 75, _startPosY + 28), + new Point(_startPosX + 50, _startPosY + 28), + } + ); + g.FillPolygon(enginesColor, new Point[] //four up TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 23), + new Point(_startPosX + 80, _startPosY + 16), + new Point(_startPosX + 80, _startPosY + 27), + } + ); + g.FillPolygon(enginesColor, new Point[] //four down + { + new Point(_startPosX + 49, _startPosY + 92), + new Point(_startPosX + 75, _startPosY + 92), + new Point(_startPosX + 75, _startPosY + 102), + new Point(_startPosX + 47, _startPosY + 102), + } + ); + g.FillPolygon(enginesColor, new Point[] //four down TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 97), + new Point(_startPosX + 80, _startPosY + 92), + new Point(_startPosX + 80, _startPosY + 105), + } + ); + } + if (amount == Engines.Six) + { + g.FillPolygon(enginesColor, new Point[] //six up + { + new Point(_startPosX + 46, _startPosY + 6), + new Point(_startPosX + 75, _startPosY + 6), + new Point(_startPosX + 75, _startPosY + 16), + new Point(_startPosX + 48, _startPosY + 16), + } + ); + g.FillPolygon(enginesColor, new Point[] //six up TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 11), + new Point(_startPosX + 80, _startPosY + 5), + new Point(_startPosX + 80, _startPosY + 17), + } + ); + g.FillPolygon(enginesColor, new Point[] //six down + { + new Point(_startPosX + 47, _startPosY + 104), + new Point(_startPosX + 75, _startPosY + 104), + new Point(_startPosX + 75, _startPosY + 114), + new Point(_startPosX + 45, _startPosY + 114), + } + ); + g.FillPolygon(enginesColor, new Point[] //six down TRIANGLE SHAPE + { + new Point(_startPosX + 73, _startPosY + 109), + new Point(_startPosX + 80, _startPosY + 103), + new Point(_startPosX + 80, _startPosY + 115), + } + ); + } + } + } +} diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index 1d3a1c3..17830fd 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -19,28 +19,28 @@ namespace AirBomber _drawningAirPlane.DrawPlane(gr); pictureBoxAirBomber.Image = bmp; } - private void buttonCreateAirPlane_Click(object sender, EventArgs e) - { - Random random = new(); - _drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), - Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); - - _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); - } private void buttonCreateAirBomber_Click(object sender, EventArgs e) { Random random = new(); _drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), - Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), - pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); + Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), + pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(1, 3)); _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); Draw(); } + private void buttonCreateAirPlane_Click(object sender, EventArgs e) + { + Random random = new(); + _drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(1, 3)); + + _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); + Draw(); + } private void buttonMove_Click(object sender, EventArgs e) { if (_drawningAirPlane == null) @@ -65,7 +65,6 @@ namespace AirBomber } Draw(); } - private void buttonStep_Click(object sender, EventArgs e) { if (_drawningAirPlane == null)