Новая логика формы FormSportCar
This commit is contained in:
parent
b2213886a7
commit
442ea73375
@ -22,12 +22,12 @@ namespace AirBomber
|
|||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
|
public DrawningAirBomber(int speed, double weight, Color bodyColor, Color
|
||||||
additionalColor, bool bombs, Color bombsColor, bool fuelTanks, int width, int height) :
|
additionalColor, bool bombs, bool fuelTanks, int width, int height) :
|
||||||
base(speed, weight, bodyColor, width, height, 160, 118)
|
base(speed, weight, bodyColor, width, height, 160, 118)
|
||||||
{
|
{
|
||||||
if (EntityAirPlane != null)
|
if (EntityAirPlane != null)
|
||||||
{
|
{
|
||||||
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, bombsColor, fuelTanks);
|
EntityAirPlane = new EntityAirBomber(speed, weight, bodyColor, additionalColor, bombs, fuelTanks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override void DrawPlane(Graphics g)
|
public override void DrawPlane(Graphics g)
|
||||||
@ -38,14 +38,13 @@ namespace AirBomber
|
|||||||
}
|
}
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
Brush additionalBrush = new SolidBrush(airBomber.AdditionalColor);
|
||||||
Brush bombsColor = new SolidBrush(airBomber.BombsColor);
|
|
||||||
base.DrawPlane(g);
|
base.DrawPlane(g);
|
||||||
// обвесы
|
// обвесы
|
||||||
g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 20, 15, 29);
|
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 20, 15, 29);
|
||||||
g.FillEllipse(bombsColor, _startPosX + 90, _startPosY + 70, 15, 29);
|
g.FillEllipse(additionalBrush, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||||
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 70, 15, 29);
|
||||||
g.FillEllipse(bombsColor, _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);
|
||||||
// fueltanks
|
// fueltanks
|
||||||
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
g.FillRectangle(additionalBrush, _startPosX + 63, _startPosY + 34, 20, 15);
|
||||||
|
@ -14,11 +14,10 @@ namespace AirBomber
|
|||||||
public Color BombsColor { get; private set; }
|
public Color BombsColor { get; private set; }
|
||||||
public bool FuelTanks { get; private set; }
|
public bool FuelTanks { get; private set; }
|
||||||
public EntityAirBomber(int speed, double weight, Color bodyColor, Color
|
public EntityAirBomber(int speed, double weight, Color bodyColor, Color
|
||||||
additionalColor, bool bombs, Color bombsColor, bool fuelTanks) : base(speed, weight, bodyColor)
|
additionalColor, bool bombs, bool fuelTanks) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
AdditionalColor = additionalColor;
|
AdditionalColor = additionalColor;
|
||||||
Bombs = bombs;
|
Bombs = bombs;
|
||||||
BombsColor = bombsColor;
|
|
||||||
FuelTanks = fuelTanks;
|
FuelTanks = fuelTanks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
24
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
24
AirBomber/AirBomber/FormAirBomber.Designer.cs
generated
@ -36,7 +36,7 @@
|
|||||||
pictureBoxAirBomber = new PictureBox();
|
pictureBoxAirBomber = new PictureBox();
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
buttonCreateAirPlane = new Button();
|
buttonCreateAirPlane = new Button();
|
||||||
buttonStep = new Button();
|
buttonStrategyStep = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxAirBomber).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -131,23 +131,23 @@
|
|||||||
buttonCreateAirPlane.UseVisualStyleBackColor = true;
|
buttonCreateAirPlane.UseVisualStyleBackColor = true;
|
||||||
buttonCreateAirPlane.Click += buttonCreateAirPlane_Click;
|
buttonCreateAirPlane.Click += buttonCreateAirPlane_Click;
|
||||||
//
|
//
|
||||||
// buttonStep
|
// buttonStrategyStep
|
||||||
//
|
//
|
||||||
buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonStrategyStep.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonStep.Location = new Point(862, 77);
|
buttonStrategyStep.Location = new Point(862, 77);
|
||||||
buttonStep.Name = "buttonStep";
|
buttonStrategyStep.Name = "buttonStrategyStep";
|
||||||
buttonStep.Size = new Size(112, 49);
|
buttonStrategyStep.Size = new Size(112, 49);
|
||||||
buttonStep.TabIndex = 8;
|
buttonStrategyStep.TabIndex = 8;
|
||||||
buttonStep.Text = "Шаг";
|
buttonStrategyStep.Text = "Шаг";
|
||||||
buttonStep.UseVisualStyleBackColor = true;
|
buttonStrategyStep.UseVisualStyleBackColor = true;
|
||||||
buttonStep.Click += buttonStep_Click;
|
buttonStrategyStep.Click += buttonStrategyStep_Click;
|
||||||
//
|
//
|
||||||
// FormAirBomber
|
// FormAirBomber
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(986, 540);
|
ClientSize = new Size(986, 540);
|
||||||
Controls.Add(buttonStep);
|
Controls.Add(buttonStrategyStep);
|
||||||
Controls.Add(buttonCreateAirPlane);
|
Controls.Add(buttonCreateAirPlane);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
@ -172,6 +172,6 @@
|
|||||||
private PictureBox pictureBoxAirBomber;
|
private PictureBox pictureBoxAirBomber;
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonCreateAirPlane;
|
private Button buttonCreateAirPlane;
|
||||||
private Button buttonStep;
|
private Button buttonStrategyStep;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,10 +6,17 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Стратегия перемещения
|
/// Стратегия перемещения
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private AbstractStrategy? _abstractStrategy;
|
private AbstractStrategy? _strategy;
|
||||||
|
/// <summary>
|
||||||
|
/// Выбранный самолет
|
||||||
|
/// </summary>
|
||||||
|
public DrawningAirPlane? SelectedPlane { get; private set; }
|
||||||
|
|
||||||
public FormAirBomber()
|
public FormAirBomber()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_strategy = null;
|
||||||
|
SelectedPlane = null;
|
||||||
}
|
}
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
@ -25,25 +32,33 @@
|
|||||||
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)),
|
Color color = 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)),
|
//TODO выбор основного цвета
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
|
||||||
Convert.ToBoolean(random.Next(0, 2)),
|
Color dopColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
|
||||||
pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
//TODO выбор дополнительного цвета
|
||||||
|
|
||||||
|
_drawningAirPlane = new DrawningAirBomber(random.Next(100, 300), random.Next(1000, 3000), color, dopColor,
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||||
|
|
||||||
_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)
|
private void buttonCreateAirPlane_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new();
|
Random random = new();
|
||||||
_drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000),
|
Color color = 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)),
|
|
||||||
pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
_drawningAirPlane = new DrawningAirPlane(random.Next(100, 300), random.Next(1000, 3000), color, pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||||
|
|
||||||
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningAirPlane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
Draw();
|
Draw();
|
||||||
|
|
||||||
}
|
}
|
||||||
private void buttonMove_Click(object sender, EventArgs e)
|
private void buttonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -69,7 +84,7 @@
|
|||||||
}
|
}
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
private void buttonStep_Click(object sender, EventArgs e)
|
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningAirPlane == null)
|
if (_drawningAirPlane == null)
|
||||||
{
|
{
|
||||||
@ -77,34 +92,42 @@
|
|||||||
}
|
}
|
||||||
if (comboBoxStrategy.Enabled)
|
if (comboBoxStrategy.Enabled)
|
||||||
{
|
{
|
||||||
_abstractStrategy = comboBoxStrategy.SelectedIndex
|
_strategy = comboBoxStrategy.SelectedIndex switch
|
||||||
switch
|
|
||||||
{
|
{
|
||||||
0 => new MoveToCenter(),
|
0 => new MoveToCenter(),
|
||||||
1 => new MoveToBorder(),
|
1 => new MoveToBorder(),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
if (_abstractStrategy == null)
|
if (_strategy == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_abstractStrategy.SetData(new
|
_strategy.SetData(_drawningAirPlane.GetMoveableObject,
|
||||||
DrawningObjectAirPlane(_drawningAirPlane), pictureBoxAirBomber.Width,
|
pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||||
pictureBoxAirBomber.Height);
|
|
||||||
comboBoxStrategy.Enabled = false;
|
|
||||||
}
|
}
|
||||||
if (_abstractStrategy == null)
|
if (_strategy == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_abstractStrategy.MakeStep();
|
comboBoxStrategy.Enabled = false;
|
||||||
|
_strategy.MakeStep();
|
||||||
Draw();
|
Draw();
|
||||||
if (_abstractStrategy.GetStatus() == Status.Finish)
|
if (_strategy.GetStatus() == Status.Finish)
|
||||||
{
|
{
|
||||||
comboBoxStrategy.Enabled = true;
|
comboBoxStrategy.Enabled = true;
|
||||||
_abstractStrategy = null;
|
_strategy = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Выбор самолета
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void ButtonSelectPlane_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SelectedPlane = _drawningAirPlane;
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user