Всё сделано для усложненки вроде
This commit is contained in:
parent
294c75c51c
commit
d2624a12bb
@ -89,7 +89,5 @@ namespace AirBomber
|
|||||||
engine.GetShape()
|
engine.GetShape()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
||||||
|
|
||||||
namespace AirBomber
|
namespace AirBomber
|
||||||
{
|
{
|
||||||
@ -14,16 +15,73 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
private DrawningAirPlane _drawningAirPlane;
|
private DrawningAirPlane _drawningAirPlane;
|
||||||
private AdditionalGeneric<EntityAirPlane, IDrawningEngines> additionalGeneric;
|
private AdditionalGeneric<EntityAirPlane, IDrawningEngines> additionalGeneric;
|
||||||
private readonly int _pictureWidth = 200;
|
private readonly int _pictureWidth = 400;
|
||||||
private readonly int _pictureHeight = 200;
|
private readonly int _pictureHeight = 400;
|
||||||
|
Random random = new Random();
|
||||||
public FormAdditionalGeneric()
|
public FormAdditionalGeneric()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
private void Draw()
|
||||||
|
{
|
||||||
|
if (_drawningAirPlane == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Bitmap bmp = new(pictureBoxObject.Width, pictureBoxObject.Height);
|
||||||
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
|
_drawningAirPlane.DrawPlane(gr);
|
||||||
|
pictureBoxObject.Image = bmp;
|
||||||
|
}
|
||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_drawningAirPlane = additionalGeneric.CreateDrawObject();
|
int size = random.Next(1, 10);
|
||||||
|
additionalGeneric = new AdditionalGeneric<EntityAirPlane, IDrawningEngines>(size, _pictureWidth, _pictureHeight);
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
{
|
||||||
|
EntityAirPlane plane = CreateRandomPlane();
|
||||||
|
IDrawningEngines engines = CreateRandomEngines();
|
||||||
|
additionalGeneric.Add(plane);
|
||||||
|
additionalGeneric.Add(engines);
|
||||||
|
_drawningAirPlane = additionalGeneric.CreateDrawObject();
|
||||||
|
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityAirPlane CreateRandomPlane()
|
||||||
|
{
|
||||||
|
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
|
EntityAirPlane plane;
|
||||||
|
switch (random.Next(0, 2))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
plane = new EntityAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor, Convert.ToBoolean(random.Next(2)), Convert.ToBoolean(random.Next(2)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
plane = new EntityAirPlane(random.Next(100, 300), random.Next(1000, 3000), color);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return plane;
|
||||||
|
}
|
||||||
|
public IDrawningEngines CreateRandomEngines()
|
||||||
|
{
|
||||||
|
IDrawningEngines engines;
|
||||||
|
switch (random.Next(3))
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
engines = new DrawningEnginesTriangle();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
engines = new DrawningEnginesCircle();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
engines = new DrawningEnginesRectangle();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
engines.SetAmount((random.Next(1, 4) * 2));
|
||||||
|
return engines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
AirBomber/AirBomber/FormPlaneCollection.Designer.cs
generated
13
AirBomber/AirBomber/FormPlaneCollection.Designer.cs
generated
@ -34,12 +34,14 @@
|
|||||||
maskedTextBoxNumber = new MaskedTextBox();
|
maskedTextBoxNumber = new MaskedTextBox();
|
||||||
buttonAddPlane = new Button();
|
buttonAddPlane = new Button();
|
||||||
pictureBoxCollection = new PictureBox();
|
pictureBoxCollection = new PictureBox();
|
||||||
|
buttonToFormAddGeneric = new Button();
|
||||||
groupBoxTools.SuspendLayout();
|
groupBoxTools.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCollection).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupBoxTools
|
// groupBoxTools
|
||||||
//
|
//
|
||||||
|
groupBoxTools.Controls.Add(buttonToFormAddGeneric);
|
||||||
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
groupBoxTools.Controls.Add(buttonRefreshCollection);
|
||||||
groupBoxTools.Controls.Add(buttonRemovePlane);
|
groupBoxTools.Controls.Add(buttonRemovePlane);
|
||||||
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
groupBoxTools.Controls.Add(maskedTextBoxNumber);
|
||||||
@ -99,6 +101,16 @@
|
|||||||
pictureBoxCollection.TabIndex = 1;
|
pictureBoxCollection.TabIndex = 1;
|
||||||
pictureBoxCollection.TabStop = false;
|
pictureBoxCollection.TabStop = false;
|
||||||
//
|
//
|
||||||
|
// buttonToFormAddGeneric
|
||||||
|
//
|
||||||
|
buttonToFormAddGeneric.Location = new Point(17, 545);
|
||||||
|
buttonToFormAddGeneric.Name = "buttonToFormAddGeneric";
|
||||||
|
buttonToFormAddGeneric.Size = new Size(290, 61);
|
||||||
|
buttonToFormAddGeneric.TabIndex = 4;
|
||||||
|
buttonToFormAddGeneric.Text = "Перейти к генерации объектов";
|
||||||
|
buttonToFormAddGeneric.UseVisualStyleBackColor = true;
|
||||||
|
buttonToFormAddGeneric.Click += buttonToFormAddGeneric_Click;
|
||||||
|
//
|
||||||
// FormPlaneCollection
|
// FormPlaneCollection
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
@ -122,5 +134,6 @@
|
|||||||
private MaskedTextBox maskedTextBoxNumber;
|
private MaskedTextBox maskedTextBoxNumber;
|
||||||
private Button buttonAddPlane;
|
private Button buttonAddPlane;
|
||||||
private PictureBox pictureBoxCollection;
|
private PictureBox pictureBoxCollection;
|
||||||
|
private Button buttonToFormAddGeneric;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -55,5 +55,10 @@ namespace AirBomber
|
|||||||
{
|
{
|
||||||
pictureBoxCollection.Image = _planes.ShowPlanes();
|
pictureBoxCollection.Image = _planes.ShowPlanes();
|
||||||
}
|
}
|
||||||
|
private void buttonToFormAddGeneric_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FormAdditionalGeneric form = new();
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user