From 06987670c497bab4e6bf013107a1ba445b0558cd Mon Sep 17 00:00:00 2001 From: Katerina881 Date: Mon, 3 Oct 2022 15:58:09 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9A=D0=BE=D0=BD=D0=B5=D1=86..=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectPlane/ProjectPlane/DrawingWarPlane.cs | 13 +---- ProjectPlane/ProjectPlane/EntityWarPlane.cs | 21 +++---- ProjectPlane/ProjectPlane/FormMap.Designer.cs | 5 ++ ProjectPlane/ProjectPlane/FormMap.cs | 15 ++++- ProjectPlane/ProjectPlane/SkyMap.cs | 57 +++++++++++++++++++ 5 files changed, 86 insertions(+), 25 deletions(-) create mode 100644 ProjectPlane/ProjectPlane/SkyMap.cs diff --git a/ProjectPlane/ProjectPlane/DrawingWarPlane.cs b/ProjectPlane/ProjectPlane/DrawingWarPlane.cs index 4e53212..7dfe2d2 100644 --- a/ProjectPlane/ProjectPlane/DrawingWarPlane.cs +++ b/ProjectPlane/ProjectPlane/DrawingWarPlane.cs @@ -21,7 +21,7 @@ namespace ProjectPlane public DrawingWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool isBomber, bool isFighter, bool superTurbine) : base(speed, weight, bodyColor, 110, 60) { - Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, isBomber, isFighter, superTurbine); + Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, isFighter, superTurbine); } public override void DrawTransport(Graphics g) { @@ -52,16 +52,7 @@ namespace ProjectPlane _startPosX -= 10; _startPosY -= 5; - if (warplane.IsBomber) - { - g.FillEllipse(brBlack, _startPosX + 88, _startPosY + 20, 4, 4); - g.FillRectangle(Brush, _startPosX + 60, _startPosY + 20, 30, 12); - - } - - - - if (warplane.IsFighter) + if (warplane.extraCell) { Point[] Nose = new Point[4]; Nose[0].X = Convert.ToInt32(_startPosX + 118); Nose[0].Y = Convert.ToInt32(_startPosY + 22); diff --git a/ProjectPlane/ProjectPlane/EntityWarPlane.cs b/ProjectPlane/ProjectPlane/EntityWarPlane.cs index 47d698d..7346267 100644 --- a/ProjectPlane/ProjectPlane/EntityWarPlane.cs +++ b/ProjectPlane/ProjectPlane/EntityWarPlane.cs @@ -15,14 +15,11 @@ namespace ProjectPlane /// Дополнительный цвет /// public Color DopColor { get; private set; } + /// - /// Бомбандировщик ли + /// доп отсек /// - public bool IsBomber { get; private set; } - /// - /// Истребитель ли - /// - public bool IsFighter { get; private set; } + public bool extraCell { get; private set; } /// /// наличие супертурбины /// @@ -32,18 +29,16 @@ namespace ProjectPlane /// Инициализация свойств /// /// Скорость - /// Вес автомобиля - /// Цвет кузова + /// Вес самолета + /// Цвет корпуса /// Дополнительный цвет - /// Признак наличия обвеса - /// Признак наличия антикрыла + /// Признак наличия доп остсека> /// - public EntityWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool superturbine) : + public EntityWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool cell, bool superturbine) : base(speed, weight, bodyColor) { DopColor = dopColor; - IsBomber = bodyKit; - IsFighter = wing; + extraCell = cell; SuperTurbine = superturbine; } } diff --git a/ProjectPlane/ProjectPlane/FormMap.Designer.cs b/ProjectPlane/ProjectPlane/FormMap.Designer.cs index ebc5468..c368940 100644 --- a/ProjectPlane/ProjectPlane/FormMap.Designer.cs +++ b/ProjectPlane/ProjectPlane/FormMap.Designer.cs @@ -108,6 +108,7 @@ this.pictureBoxPlane.Size = new System.Drawing.Size(800, 450); this.pictureBoxPlane.TabIndex = 5; this.pictureBoxPlane.TabStop = false; + // // statusStrip1 // @@ -155,10 +156,14 @@ // this.comboMapSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboMapSelector.FormattingEnabled = true; + this.comboMapSelector.Items.AddRange(new object[] { + "Simple Map", + "Sky Map"}); this.comboMapSelector.Location = new System.Drawing.Point(12, 12); this.comboMapSelector.Name = "comboMapSelector"; this.comboMapSelector.Size = new System.Drawing.Size(121, 23); this.comboMapSelector.TabIndex = 11; + this.comboMapSelector.SelectedIndexChanged += new System.EventHandler(this.comboMapSelector_SelectedIndexChanged); // // FormMap // diff --git a/ProjectPlane/ProjectPlane/FormMap.cs b/ProjectPlane/ProjectPlane/FormMap.cs index 449b147..4ba845e 100644 --- a/ProjectPlane/ProjectPlane/FormMap.cs +++ b/ProjectPlane/ProjectPlane/FormMap.cs @@ -18,6 +18,19 @@ namespace ProjectPlane InitializeComponent(); _abstractMap = new SimpleMap(); } + + private void comboMapSelector_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboMapSelector.SelectedIndex) + { + case 0: + _abstractMap = new SimpleMap(); + break; + case 1: + _abstractMap = new SkyMap(); + break; + } + } /// private void SetData(DrawingPlane plane) { @@ -78,7 +91,7 @@ namespace ProjectPlane SetData(_plane); } - + } } diff --git a/ProjectPlane/ProjectPlane/SkyMap.cs b/ProjectPlane/ProjectPlane/SkyMap.cs new file mode 100644 index 0000000..b58bbdf --- /dev/null +++ b/ProjectPlane/ProjectPlane/SkyMap.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectPlane +{ + internal class SkyMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Black); + /// + /// Цвет участка открытого + /// + private readonly Brush skyColor = new SolidBrush(Color.AliceBlue); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + Point[] Triangle = new Point[3]; + Triangle[0].X = i * (int)_size_x; Triangle[0].Y = j * (int)_size_y; + Triangle[1].X = i * (int)_size_x + 8; Triangle[1].Y = j * (int)_size_y - 5; + Triangle[2].X = i * (int)_size_x + 8; Triangle[2].Y = j * (int)_size_y + 5; + g.FillPolygon(barrierColor, Triangle); + } + protected override void DrawRoadPart(Graphics g, int i, int j) + { + g.FillRectangle(skyColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1)); + } + protected override void GenerateMap() + { + _map = new int[100, 100]; + _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 j = 0; j < _map.GetLength(1); ++j) + { + _map[i, j] = _freeRoad; + } + } + while (counter < 30) + { + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +}