diff --git a/Locomotives/Locomotives/AbstractMap.cs b/Locomotives/Locomotives/AbstractMap.cs
index f27ed6e..2708099 100644
--- a/Locomotives/Locomotives/AbstractMap.cs
+++ b/Locomotives/Locomotives/AbstractMap.cs
@@ -186,7 +186,6 @@
int x = _random.Next(10, 100);
int y = _random.Next(10, 100);
_drawningObject.SetObject(x, y, _width, _height);
- // TODO првоерка, что объект не "накладывается" на закрытые участки
if (!AbleToSetObject())
{
return false;
diff --git a/Locomotives/Locomotives/CrossMap.cs b/Locomotives/Locomotives/CrossMap.cs
index fc41c06..ffb23b0 100644
--- a/Locomotives/Locomotives/CrossMap.cs
+++ b/Locomotives/Locomotives/CrossMap.cs
@@ -26,9 +26,9 @@
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
- for (int i = 0; i < _map.GetLength(0); ++i)
+ for (int i = 0; i < _map.GetLength(0); i++)
{
- for (int j = 0; j < _map.GetLength(1); ++j)
+ for (int j = 0; j < _map.GetLength(1); j++)
{
_map[i, j] = _freeRoad;
}
diff --git a/Locomotives/Locomotives/FormLocomotive.Designer.cs b/Locomotives/Locomotives/FormLocomotive.Designer.cs
index 0f12d4e..cce3c09 100644
--- a/Locomotives/Locomotives/FormLocomotive.Designer.cs
+++ b/Locomotives/Locomotives/FormLocomotive.Designer.cs
@@ -33,11 +33,15 @@
this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel();
this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelAdditionalColor = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelHasPipe = new System.Windows.Forms.ToolStripStatusLabel();
+ this.toolStripStatusLabelHasFuelTank = new System.Windows.Forms.ToolStripStatusLabel();
this.buttonCreate = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonCreateModif = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxLocomotive)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -59,7 +63,10 @@
this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripStatusLabelSpeed,
this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelBodyColor});
+ this.toolStripStatusLabelBodyColor,
+ this.toolStripStatusLabelAdditionalColor,
+ this.toolStripStatusLabelHasPipe,
+ this.toolStripStatusLabelHasFuelTank});
this.statusStrip.Location = new System.Drawing.Point(0, 428);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 22);
@@ -84,6 +91,24 @@
this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(39, 17);
this.toolStripStatusLabelBodyColor.Text = "Цвет: ";
//
+ // toolStripStatusLabelAdditionalColor
+ //
+ this.toolStripStatusLabelAdditionalColor.Name = "toolStripStatusLabelAdditionalColor";
+ this.toolStripStatusLabelAdditionalColor.Size = new System.Drawing.Size(137, 17);
+ this.toolStripStatusLabelAdditionalColor.Text = "Дополнительный цвет: ";
+ //
+ // toolStripStatusLabelHasPipe
+ //
+ this.toolStripStatusLabelHasPipe.Name = "toolStripStatusLabelHasPipe";
+ this.toolStripStatusLabelHasPipe.Size = new System.Drawing.Size(99, 17);
+ this.toolStripStatusLabelHasPipe.Text = "Наличие трубы: ";
+ //
+ // toolStripStatusLabelHasFuelTank
+ //
+ this.toolStripStatusLabelHasFuelTank.Name = "toolStripStatusLabelHasFuelTank";
+ this.toolStripStatusLabelHasFuelTank.Size = new System.Drawing.Size(158, 17);
+ this.toolStripStatusLabelHasFuelTank.Text = "Наличие топливного бака: ";
+ //
// buttonCreate
//
this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
@@ -143,11 +168,23 @@
this.buttonUp.UseVisualStyleBackColor = true;
this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
//
+ // buttonCreateModif
+ //
+ this.buttonCreateModif.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
+ this.buttonCreateModif.Location = new System.Drawing.Point(108, 395);
+ this.buttonCreateModif.Name = "buttonCreateModif";
+ this.buttonCreateModif.Size = new System.Drawing.Size(109, 30);
+ this.buttonCreateModif.TabIndex = 8;
+ this.buttonCreateModif.Text = "Модификация";
+ this.buttonCreateModif.UseVisualStyleBackColor = true;
+ this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
+ //
// FormLocomotive
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonDown);
this.Controls.Add(this.buttonLeft);
@@ -177,5 +214,9 @@
private Button buttonLeft;
private Button buttonDown;
private Button buttonUp;
+ private ToolStripStatusLabel toolStripStatusLabelAdditionalColor;
+ private ToolStripStatusLabel toolStripStatusLabelHasPipe;
+ private ToolStripStatusLabel toolStripStatusLabelHasFuelTank;
+ private Button buttonCreateModif;
}
}
\ No newline at end of file
diff --git a/Locomotives/Locomotives/FormLocomotive.cs b/Locomotives/Locomotives/FormLocomotive.cs
index 20d5cbe..3a6d467 100644
--- a/Locomotives/Locomotives/FormLocomotive.cs
+++ b/Locomotives/Locomotives/FormLocomotive.cs
@@ -22,6 +22,34 @@
pictureBoxLocomotive.Image = bmp;
}
///
+ /// Заполнение информации по объекту
+ ///
+ /// Объект от класса отрисовки или его наследника
+ private void SetData(DrawningLocomotive locomotive)
+ {
+ Random rnd = new();
+ toolStripStatusLabelSpeed.Text = $"Скорость: {locomotive.Locomotive.Speed}";
+ toolStripStatusLabelWeight.Text = $"Вес: {locomotive.Locomotive.Weight}";
+ toolStripStatusLabelBodyColor.Text = $"Цвет: {locomotive.Locomotive.BodyColor.Name}";
+ toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: н/д";
+ toolStripStatusLabelHasPipe.Text = $"Наличие трубы: н/д";
+ toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: н/д";
+ _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
+ }
+ ///
+ /// Заполнение дополнительной информации по объекту (только для усложнённого объекта)
+ ///
+ /// Объект от наследника класса отрисовки
+ private void SetAdditionalData(DrawningWarmlyLocomotive warmlylocomotive)
+ {
+ if (warmlylocomotive.Locomotive is EntityWarmlyLocomotive entityWarmlyLocomotive)
+ {
+ toolStripStatusLabelAdditionalColor.Text = $"Дополнительный цвет: {entityWarmlyLocomotive.AdditionalColor.Name}";
+ toolStripStatusLabelHasPipe.Text = $"Наличие трубы: {entityWarmlyLocomotive.HasPipe}";
+ toolStripStatusLabelHasFuelTank.Text = $"Наличие топливного бака: {entityWarmlyLocomotive.HasFuelTank}";
+ }
+ }
+ ///
/// Метод обработки нажатия на кнопку "Создать"
///
///
@@ -30,10 +58,7 @@
{
Random rnd = new();
_locomotive = new DrawningLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- _locomotive.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
- toolStripStatusLabelSpeed.Text = $"Скорость: {_locomotive.Locomotive.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {_locomotive.Locomotive.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет: {_locomotive.Locomotive.BodyColor.Name}";
+ SetData(_locomotive);
Draw();
}
///
@@ -72,5 +97,23 @@
_locomotive?.ChangeBorders(pictureBoxLocomotive.Width, pictureBoxLocomotive.Height);
Draw();
}
+ ///
+ /// Обработка нажатия кнопки "Модификация"
+ ///
+ ///
+ ///
+ private void ButtonCreateModif_Click(object sender, EventArgs e)
+ {
+ Random rnd = new();
+ _locomotive = new DrawningWarmlyLocomotive(rnd.Next(100, 300), rnd.Next(1000, 2000),
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
+ 160, 85,
+ Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
+ Convert.ToBoolean(rnd.Next(0, 2)),
+ Convert.ToBoolean(rnd.Next(0, 2)));
+ SetData(_locomotive);
+ SetAdditionalData((DrawningWarmlyLocomotive)_locomotive);
+ Draw();
+ }
}
}
diff --git a/Locomotives/Locomotives/RoadsMap.cs b/Locomotives/Locomotives/RoadsMap.cs
index 84aeb69..28d1973 100644
--- a/Locomotives/Locomotives/RoadsMap.cs
+++ b/Locomotives/Locomotives/RoadsMap.cs
@@ -26,9 +26,9 @@
_map = new int[100, 100];
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
- for (int i = 0; i < _map.GetLength(0); ++i)
+ for (int i = 0; i < _map.GetLength(0); i++)
{
- for (int j = 0; j < _map.GetLength(1); ++j)
+ for (int j = 0; j < _map.GetLength(1); j++)
{
_map[i, j] = _freeRoad;
}
diff --git a/Locomotives/Locomotives/SimpleMap.cs b/Locomotives/Locomotives/SimpleMap.cs
index 0a3969b..9c3f5b6 100644
--- a/Locomotives/Locomotives/SimpleMap.cs
+++ b/Locomotives/Locomotives/SimpleMap.cs
@@ -27,9 +27,9 @@
_size_x = (float)_width / _map.GetLength(0);
_size_y = (float)_height / _map.GetLength(1);
int counter = 0;
- for (int i = 0; i < _map.GetLength(0); ++i)
+ for (int i = 0; i < _map.GetLength(0); i++)
{
- for (int j = 0; j < _map.GetLength(1); ++j)
+ for (int j = 0; j < _map.GetLength(1); j++)
{
_map[i, j] = _freeRoad;
}