diff --git a/AirBomber/AirBomber/AbstractMap.cs b/AirBomber/AirBomber/AbstractMap.cs index 78425d8..8cc655f 100644 --- a/AirBomber/AirBomber/AbstractMap.cs +++ b/AirBomber/AirBomber/AbstractMap.cs @@ -162,7 +162,7 @@ namespace AirBomber DrawMap(); if (_staticBitMap != null) gr.DrawImage(_staticBitMap, 0, 0); - _drawningObject.DrawningObject(gr); + _drawningObject.DrawObject(gr); return bmp; } diff --git a/AirBomber/AirBomber/DrawningObject.cs b/AirBomber/AirBomber/DrawningObject.cs index d79a291..eeb55c0 100644 --- a/AirBomber/AirBomber/DrawningObject.cs +++ b/AirBomber/AirBomber/DrawningObject.cs @@ -32,7 +32,7 @@ namespace AirBomber _airplane.SetPosition(x, y, width, height); } - void IDrawningObject.DrawningObject(Graphics g) + public void DrawObject(Graphics g) { _airplane.DrawTransport(g); } diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs index 294d009..013e662 100644 --- a/AirBomber/AirBomber/FormAirBomber.Designer.cs +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); this.statusStrip = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); @@ -39,20 +39,20 @@ this.buttonRight = new System.Windows.Forms.Button(); this.buttonDown = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); // - // pictureBoxCar + // pictureBoxAirplane // - this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); - this.pictureBoxCar.Name = "pictureBoxCar"; - this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); - this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxCar.TabIndex = 0; - this.pictureBoxCar.TabStop = false; - this.pictureBoxCar.Resize += new System.EventHandler(this.PictureBoxCar_Resize); + this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); + this.pictureBoxAirplane.Name = "pictureBoxAirplane"; + this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 428); + this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxAirplane.TabIndex = 0; + this.pictureBoxAirplane.TabStop = false; + this.pictureBoxAirplane.Resize += new System.EventHandler(this.PictureBoxAirplane_Resize); // // statusStrip // @@ -164,11 +164,11 @@ this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.pictureBoxAirplane); this.Controls.Add(this.statusStrip); this.Name = "FormAirBomber"; this.Text = "Самолет"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.ResumeLayout(false); @@ -178,7 +178,7 @@ #endregion - private PictureBox pictureBoxCar; + private PictureBox pictureBoxAirplane; private StatusStrip statusStrip; private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; diff --git a/AirBomber/AirBomber/FormAirBomber.cs b/AirBomber/AirBomber/FormAirBomber.cs index f177f21..8eaaa46 100644 --- a/AirBomber/AirBomber/FormAirBomber.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -9,14 +9,14 @@ namespace AirBomber InitializeComponent(); } /// - /// + /// /// private void Draw() { - Bitmap bmp = new(pictureBoxCar.Width, pictureBoxCar.Height); + Bitmap bmp = new(pictureBoxAirplane.Width, pictureBoxAirplane.Height); Graphics gr = Graphics.FromImage(bmp); _airplane?.DrawTransport(gr); - pictureBoxCar.Image = bmp; + pictureBoxAirplane.Image = bmp; } /// /// @@ -24,7 +24,7 @@ namespace AirBomber private void SetData() { Random rnd = new(); - _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxCar.Width, pictureBoxCar.Height); + _airplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirplane.Width, pictureBoxAirplane.Height); toolStripStatusLabelSpeed.Text = $": {_airplane.Airplane.Speed}"; toolStripStatusLabelWeight.Text = $": {_airplane.Airplane.Weight}"; toolStripStatusLabelBodyColor.Text = $": {_airplane.Airplane.BodyColor.Name}"; @@ -72,9 +72,9 @@ namespace AirBomber /// /// /// - private void PictureBoxCar_Resize(object sender, EventArgs e) + private void PictureBoxAirplane_Resize(object sender, EventArgs e) { - _airplane?.ChangeBorders(pictureBoxCar.Width, pictureBoxCar.Height); + _airplane?.ChangeBorders(pictureBoxAirplane.Width, pictureBoxAirplane.Height); Draw(); } /// diff --git a/AirBomber/AirBomber/FormMap.Designer.cs b/AirBomber/AirBomber/FormMap.Designer.cs index 54ebe8b..6781998 100644 --- a/AirBomber/AirBomber/FormMap.Designer.cs +++ b/AirBomber/AirBomber/FormMap.Designer.cs @@ -28,7 +28,7 @@ /// private void InitializeComponent() { - this.pictureBoxCar = new System.Windows.Forms.PictureBox(); + this.pictureBoxAirplane = new System.Windows.Forms.PictureBox(); this.statusStrip = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); @@ -40,19 +40,19 @@ this.buttonDown = new System.Windows.Forms.Button(); this.buttonCreateModif = new System.Windows.Forms.Button(); this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox(); - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); // - // pictureBoxCar + // pictureBoxAirplane // - this.pictureBoxCar.Dock = System.Windows.Forms.DockStyle.Fill; - this.pictureBoxCar.Location = new System.Drawing.Point(0, 0); - this.pictureBoxCar.Name = "pictureBoxCar"; - this.pictureBoxCar.Size = new System.Drawing.Size(800, 428); - this.pictureBoxCar.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; - this.pictureBoxCar.TabIndex = 0; - this.pictureBoxCar.TabStop = false; + this.pictureBoxAirplane.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxAirplane.Location = new System.Drawing.Point(0, 0); + this.pictureBoxAirplane.Name = "pictureBoxAirplane"; + this.pictureBoxAirplane.Size = new System.Drawing.Size(800, 428); + this.pictureBoxAirplane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxAirplane.TabIndex = 0; + this.pictureBoxAirplane.TabStop = false; // // statusStrip // @@ -178,11 +178,11 @@ this.Controls.Add(this.buttonLeft); this.Controls.Add(this.buttonUp); this.Controls.Add(this.buttonCreate); - this.Controls.Add(this.pictureBoxCar); + this.Controls.Add(this.pictureBoxAirplane); this.Controls.Add(this.statusStrip); this.Name = "FormMap"; this.Text = "Карта"; - ((System.ComponentModel.ISupportInitialize)(this.pictureBoxCar)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirplane)).EndInit(); this.statusStrip.ResumeLayout(false); this.statusStrip.PerformLayout(); this.ResumeLayout(false); @@ -192,7 +192,7 @@ #endregion - private PictureBox pictureBoxCar; + private PictureBox pictureBoxAirplane; private StatusStrip statusStrip; private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; diff --git a/AirBomber/AirBomber/FormMap.cs b/AirBomber/AirBomber/FormMap.cs index c311927..8bd4c48 100644 --- a/AirBomber/AirBomber/FormMap.cs +++ b/AirBomber/AirBomber/FormMap.cs @@ -14,14 +14,14 @@ namespace AirBomber /// /// Заполнение информации по объекту /// - /// - private void SetData(DrawningAirplane car) + /// + private void SetData(DrawningAirplane airplane) { - toolStripStatusLabelSpeed.Text = $"Скорость: {car.Airplane.Speed}"; - toolStripStatusLabelWeight.Text = $"Вес: {car.Airplane.Weight}"; - toolStripStatusLabelBodyColor.Text = $"Цвет: {car.Airplane.BodyColor.Name}"; - pictureBoxCar.Image = _abstractMap.CreateMap(pictureBoxCar.Width, pictureBoxCar.Height, - new DrawningObject(car)); + toolStripStatusLabelSpeed.Text = $"Скорость: {airplane.Airplane.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {airplane.Airplane.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет: {airplane.Airplane.BodyColor.Name}"; + pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height, + new DrawningObject(airplane)); } /// /// Обработка нажатия кнопки "Создать" @@ -31,8 +31,8 @@ namespace AirBomber private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - var car = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - SetData(car); + var airplane = new DrawningAirplane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(airplane); } /// /// Изменение размеров формы @@ -59,7 +59,7 @@ namespace AirBomber dir = Direction.Right; break; } - pictureBoxCar.Image = _abstractMap?.MoveObject(dir); + pictureBoxAirplane.Image = _abstractMap?.MoveObject(dir); } /// /// Обработка нажатия кнопки "Модификация" @@ -69,11 +69,11 @@ namespace AirBomber private void ButtonCreateModif_Click(object sender, EventArgs e) { Random rnd = new(); - var car = new DrawningAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), + var airplane = new DrawningAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), 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(car); + SetData(airplane); } /// /// Смена карты diff --git a/AirBomber/AirBomber/IDrawningObject.cs b/AirBomber/AirBomber/IDrawningObject.cs index 6077012..a2afce7 100644 --- a/AirBomber/AirBomber/IDrawningObject.cs +++ b/AirBomber/AirBomber/IDrawningObject.cs @@ -33,7 +33,7 @@ namespace AirBomber /// Отрисовка объекта /// /// - void DrawningObject(Graphics g); + void DrawObject(Graphics g); /// /// Получение текущей позиции объекта /// diff --git a/AirBomber/AirBomber/SimpleMap.cs b/AirBomber/AirBomber/SimpleMap.cs index 63bb878..f5f9a69 100644 --- a/AirBomber/AirBomber/SimpleMap.cs +++ b/AirBomber/AirBomber/SimpleMap.cs @@ -16,11 +16,11 @@ protected override void DrawBarrierPart(Graphics g, int i, int j) { - g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void DrawRoadPart(Graphics g, int i, int j) { - g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void GenerateMap() { diff --git a/AirBomber/AirBomber/WallMap.cs b/AirBomber/AirBomber/WallMap.cs index 8cb7989..59273aa 100644 --- a/AirBomber/AirBomber/WallMap.cs +++ b/AirBomber/AirBomber/WallMap.cs @@ -31,7 +31,7 @@ namespace AirBomber protected override void DrawRoadPart(Graphics g, int i, int j) { - g.FillRectangle(roadColor, i * _size_x, j * _size_y, (i + 1) * _size_x, (j + 1) * _size_y); + g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y); } protected override void GenerateMap()