Compare commits

...

2 Commits

7 changed files with 275 additions and 35 deletions

View File

@ -8,8 +8,8 @@ namespace AirBomber
{ {
public class DrawningAirBomber : DrawningAirPlane public class DrawningAirBomber : DrawningAirPlane
{ {
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height) : 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, 160, 118) base(speed, weight, bodyColor, width, height, engines, enginesShape)
{ {
if (EntityAirPlane != null) if (EntityAirPlane != null)
{ {
@ -26,17 +26,17 @@ namespace AirBomber
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor); Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
base.DrawPlane(g); base.DrawPlane(g);
// bombs // 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.FillEllipse(additionalBrush, _startPosX + 140, _startPosY + 50, 15, 15);
g.DrawEllipse(pen, _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 // fueltanks
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15); g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 34, 30, 15);
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 34, 20, 15); g.DrawRectangle(pen, _startPosX + 85, _startPosY + 34, 30, 15);
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 70, 20, 15); g.FillRectangle(additionalBrush, _startPosX + 85, _startPosY + 70, 30, 15);
g.DrawRectangle(pen, _startPosX + 63, _startPosY + 70, 20, 15); g.DrawRectangle(pen, _startPosX + 85, _startPosY + 70, 30, 15);
} }
} }
} }

View File

@ -15,7 +15,8 @@ namespace AirBomber
protected int _startPosY; protected int _startPosY;
protected readonly int _airPlaneWidth = 150; protected readonly int _airPlaneWidth = 150;
protected readonly int _airPlaneHeight = 118; 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) if (width < _airPlaneWidth || height < _airPlaneHeight)
{ {
@ -24,18 +25,19 @@ namespace AirBomber
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor); EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor);
} switch (enginesShape)
protected DrawningAirPlane(int speed, double weight, Color bodyColor, int width, int height, int airPlaneWidth, int airPlaneHeight)
{
if (width < _airPlaneWidth || height < _airPlaneHeight)
{ {
return; case 1:
drawningEngines = new DrawningEnginesCircle();
break;
case 2:
drawningEngines = new DrawningEnginesTriangle();
break;
default:
drawningEngines = new DrawningEnginesRectangle();
break;
} }
_pictureWidth = width; drawningEngines.SetAmount(engines);
_pictureHeight = height;
_airPlaneWidth = airPlaneWidth;
_airPlaneHeight = airPlaneHeight;
EntityAirPlane = new EntityAirPlane(speed, weight, bodyColor);
} }
public void SetPosition(int x, int y) public void SetPosition(int x, int y)
{ {
@ -140,6 +142,7 @@ namespace AirBomber
new Point(_startPosX + 140, _startPosY + 70), new Point(_startPosX + 140, _startPosY + 70),
} }
); );
drawningEngines.DrawEngines(g, _startPosX, _startPosY);
} }
public int GetPosX => _startPosX; public int GetPosX => _startPosX;
public int GetPosY => _startPosY; public int GetPosY => _startPosY;

View File

@ -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);
}
}
}
}

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace AirBomber namespace AirBomber
{ {
internal class DrawningEngines public class DrawningEnginesRectangle : IDrawningEngines
{ {
private Engines amount; private Engines amount;
public void SetAmount(int a) public void SetAmount(int a)

View File

@ -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),
}
);
}
}
}
}

View File

@ -19,28 +19,28 @@ namespace AirBomber
_drawningAirPlane.DrawPlane(gr); _drawningAirPlane.DrawPlane(gr);
pictureBoxAirBomber.Image = bmp; 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) private void buttonCreateAirBomber_Click(object sender, EventArgs e)
{ {
Random random = new(); 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)), _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)), 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)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)),
pictureBoxAirBomber.Width, pictureBoxAirBomber.Height); pictureBoxAirBomber.Width, pictureBoxAirBomber.Height, random.Next(1, 4) * 2, random.Next(1, 3));
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100)); _drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
Draw(); 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) private void buttonMove_Click(object sender, EventArgs e)
{ {
if (_drawningAirPlane == null) if (_drawningAirPlane == null)
@ -65,7 +65,6 @@ namespace AirBomber
} }
Draw(); Draw();
} }
private void buttonStep_Click(object sender, EventArgs e) private void buttonStep_Click(object sender, EventArgs e)
{ {
if (_drawningAirPlane == null) if (_drawningAirPlane == null)

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AirBomber
{
internal interface IDrawningEngines
{
public void SetAmount(int a);
public void DrawEngines(Graphics g, int _startPosX, int _startPosY);
}
}