From 61de90a13aac84a714300d3c234a53852ccbf758 Mon Sep 17 00:00:00 2001 From: ker73rus Date: Tue, 15 Nov 2022 11:03:23 +0400 Subject: [PATCH 1/3] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B5=D1=82=D0=BE=D1=87=D0=BD?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Stormtrooper/DrawningMilitaryAirplane.cs | 6 +++--- .../Stormtrooper/DrawningStormtrooper.cs | 4 ++-- .../Stormtrooper/EntityMilitaryAirplane.cs | 6 +++--- .../Stormtrooper/EntityStormtrooper.cs | 4 ++-- Stormtrooper/Stormtrooper/FormMap.cs | 5 ++--- Stormtrooper/Stormtrooper/MainForm.cs | 21 +++++++++++++------ 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs index 6e65760..185fdb3 100644 --- a/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs +++ b/Stormtrooper/Stormtrooper/DrawningMilitaryAirplane.cs @@ -37,9 +37,9 @@ namespace Stormtrooper /// Высота отрисовки самолёта /// protected readonly int _airplaneHeight; - public DrawningMilitaryAirplane(int speed, int weight, int wight = 80, int height = 100) + public DrawningMilitaryAirplane(int speed, int weight,Color color, int wight = 80, int height = 100) { - Airplane = new EntityMilitaryAirplane(speed, weight); + Airplane = new EntityMilitaryAirplane(speed, weight, color); _airplaneWidth = wight; _airplaneHeight = height; } @@ -110,7 +110,7 @@ namespace Stormtrooper Pen pen = new Pen(Color.Black); - Brush brush = new SolidBrush(Color.DarkGreen); + Brush brush = new SolidBrush(Airplane.Color); g.FillPolygon(brush, new PointF[3] {new PointF(_startPosX, _startPosY + _airplaneHeight / 2), new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f), new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.55f)}); diff --git a/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs b/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs index 26f08dd..6665677 100644 --- a/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs +++ b/Stormtrooper/Stormtrooper/DrawningStormtrooper.cs @@ -8,9 +8,9 @@ namespace Stormtrooper { internal class DrawningStormtrooper : DrawningMilitaryAirplane { - public DrawningStormtrooper(int speed, int weight, int crew, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight) + public DrawningStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight, color) { - Airplane = new EntityStormtrooper(speed, weight,crew, advColor, rockets, boosters, radar); + Airplane = new EntityStormtrooper(speed, weight,color, advColor, rockets, boosters, radar); } public override void DrawAirplane(Graphics g) { diff --git a/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs b/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs index 6bb340d..e406587 100644 --- a/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs +++ b/Stormtrooper/Stormtrooper/EntityMilitaryAirplane.cs @@ -10,16 +10,16 @@ namespace Stormtrooper { public int Speed { get; private set; } public int Weight { get; private set; } - public int Crew { get; private set; } + public Color Color { get; private set; } public float Step => Speed * 25 / Weight; - public EntityMilitaryAirplane(int speed, int weight, int crew = 10) + public EntityMilitaryAirplane(int speed, int weight, Color color) { Random random = new Random(); Speed = speed <= 0 ? random.Next(10, 100) : speed; Weight = weight <= 0 ? random.Next(50, 150) : weight; - Crew = crew; + Color = color; } diff --git a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs index 4907b8b..44c6b41 100644 --- a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs +++ b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs @@ -25,8 +25,8 @@ namespace Stormtrooper /// public bool Radar { get; private set; } - public EntityStormtrooper(int speed, int weight, int crew, Color advColor, bool rockets, bool boosters, bool radar) - : base(speed, weight, crew) + public EntityStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar) + : base(speed, weight, color) { Rockets = rockets; Booster = boosters; diff --git a/Stormtrooper/Stormtrooper/FormMap.cs b/Stormtrooper/Stormtrooper/FormMap.cs index 520f620..8b0001a 100644 --- a/Stormtrooper/Stormtrooper/FormMap.cs +++ b/Stormtrooper/Stormtrooper/FormMap.cs @@ -22,7 +22,7 @@ namespace Stormtrooper private void buttonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - _airplane = new DrawningMilitaryAirplane(10, 50); + _airplane = new DrawningMilitaryAirplane(10, 50, Color.DarkGreen); _airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); SetData(); } @@ -53,7 +53,6 @@ namespace Stormtrooper { toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}"; toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}"; - toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}"; pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height, new DrawningObject(_airplane)); } @@ -62,7 +61,7 @@ namespace Stormtrooper { Random random = new Random(); - _airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100), + _airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250), 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)), Convert.ToBoolean(random.Next(0, 2))); _airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); diff --git a/Stormtrooper/Stormtrooper/MainForm.cs b/Stormtrooper/Stormtrooper/MainForm.cs index 76af6d6..9b97507 100644 --- a/Stormtrooper/Stormtrooper/MainForm.cs +++ b/Stormtrooper/Stormtrooper/MainForm.cs @@ -29,10 +29,15 @@ namespace Stormtrooper } private void buttonCreate_Click(object sender, EventArgs e) { - Random rnd = new Random(); - - _airplane = new DrawningMilitaryAirplane(10, 50); - _airplane.SetPosition(rnd.Next(100,150), rnd.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); + Random random = new Random(); + Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + ColorDialog dialog = new(); + if (dialog.ShowDialog() == DialogResult.OK) + { + color = dialog.Color; + } + _airplane = new DrawningMilitaryAirplane(10, 50, color); + _airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); SetData(); Draw(); } @@ -68,7 +73,6 @@ namespace Stormtrooper { toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}"; toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}"; - toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}"; } private void buttonCreateMod_Click(object sender, EventArgs e) @@ -76,12 +80,17 @@ namespace Stormtrooper Random random = new Random(); Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); + Color advColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)); ColorDialog dialog = new(); if (dialog.ShowDialog() == DialogResult.OK) { color = dialog.Color; } - _airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100), + if (dialog.ShowDialog() == DialogResult.OK) + { + advColor = dialog.Color; + } + _airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),advColor, color, Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2))); _airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height); From 5eaac57cb29b959915e114de4550ccc643508fca Mon Sep 17 00:00:00 2001 From: ker73rus Date: Mon, 28 Nov 2022 22:23:06 +0400 Subject: [PATCH 2/3] =?UTF-8?q?=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/CloudMap.cs | 3 ++- Stormtrooper/Stormtrooper/DangerMap.cs | 3 ++- Stormtrooper/Stormtrooper/FormMap.cs | 3 ++- Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs | 3 ++- Stormtrooper/Stormtrooper/SimpleMap.cs | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Stormtrooper/Stormtrooper/CloudMap.cs b/Stormtrooper/Stormtrooper/CloudMap.cs index 291072f..cc29fd9 100644 --- a/Stormtrooper/Stormtrooper/CloudMap.cs +++ b/Stormtrooper/Stormtrooper/CloudMap.cs @@ -1,4 +1,5 @@ -using System; +using Strormtrooper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Stormtrooper/Stormtrooper/DangerMap.cs b/Stormtrooper/Stormtrooper/DangerMap.cs index 86e38f9..be1280c 100644 --- a/Stormtrooper/Stormtrooper/DangerMap.cs +++ b/Stormtrooper/Stormtrooper/DangerMap.cs @@ -1,4 +1,5 @@ -using System; +using Strormtrooper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Stormtrooper/Stormtrooper/FormMap.cs b/Stormtrooper/Stormtrooper/FormMap.cs index 8b0001a..6b5cbc4 100644 --- a/Stormtrooper/Stormtrooper/FormMap.cs +++ b/Stormtrooper/Stormtrooper/FormMap.cs @@ -1,4 +1,5 @@ -using System; +using Strormtrooper; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; diff --git a/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs b/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs index a1c1d29..68c6cd3 100644 --- a/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs +++ b/Stormtrooper/Stormtrooper/MapWithSetAirplaneGeneric.cs @@ -1,4 +1,5 @@ -using System; +using Strormtrooper; +using System; using System.Collections.Generic; using System.Linq; using System.Text; diff --git a/Stormtrooper/Stormtrooper/SimpleMap.cs b/Stormtrooper/Stormtrooper/SimpleMap.cs index 84845c4..380593f 100644 --- a/Stormtrooper/Stormtrooper/SimpleMap.cs +++ b/Stormtrooper/Stormtrooper/SimpleMap.cs @@ -1,4 +1,4 @@ -namespace Stormtrooper +namespace Strormtrooper { /// /// Простая реализация абсрактного класса AbstractMap From 4d041377c39b0bcf13a6b532371d7c48de3c47c6 Mon Sep 17 00:00:00 2001 From: foxkerik6 Date: Mon, 28 Nov 2022 22:32:40 +0400 Subject: [PATCH 3/3] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs | 2 +- Stormtrooper/Stormtrooper/SimpleMap.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs index fc10273..0f8565e 100644 --- a/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs +++ b/Stormtrooper/Stormtrooper/FormMapWithSetAirplane.cs @@ -1,4 +1,4 @@ -using Cars; +using Strormtrooper; using System; using System.Collections.Generic; using System.ComponentModel; diff --git a/Stormtrooper/Stormtrooper/SimpleMap.cs b/Stormtrooper/Stormtrooper/SimpleMap.cs index 380593f..8fc5284 100644 --- a/Stormtrooper/Stormtrooper/SimpleMap.cs +++ b/Stormtrooper/Stormtrooper/SimpleMap.cs @@ -1,4 +1,6 @@ -namespace Strormtrooper +using Stormtrooper; + +namespace Strormtrooper { /// /// Простая реализация абсрактного класса AbstractMap