Всё сделано в усложненной лабе

This commit is contained in:
malimova 2023-11-26 22:01:52 +04:00
parent 52dd126a68
commit ec08a44682
6 changed files with 261 additions and 35 deletions

View File

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

View File

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

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
{
internal class DrawningEngines
public class DrawningEnginesRectangle : IDrawningEngines
{
private Engines amount;
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);
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);
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)