From f07e0ddd9e7713cab93300e75fb794d4aa43121a Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Tue, 4 Oct 2022 21:10:33 +0400 Subject: [PATCH 1/8] =?UTF-8?q?=D0=BB=D0=B0=D0=B1=202=20=D1=81=D0=BE=D0=B7?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/AbstractMap.cs | 107 ++++++++++ WarPlanes/WarPlanes/Direction.cs | 1 + WarPlanes/WarPlanes/DrawningFighter.cs | 73 +++++++ WarPlanes/WarPlanes/DrawningObject.cs | 35 ++++ WarPlanes/WarPlanes/DrawningWarplane.cs | 43 +++- WarPlanes/WarPlanes/EntityWarplane.cs | 2 +- WarPlanes/WarPlanes/Fighter.cs | 37 ++++ WarPlanes/WarPlanes/FormMap.Designer.cs | 207 +++++++++++++++++++ WarPlanes/WarPlanes/FormMap.cs | 93 +++++++++ WarPlanes/WarPlanes/FormMap.resx | 63 ++++++ WarPlanes/WarPlanes/FormWarPlane.Designer.cs | 15 +- WarPlanes/WarPlanes/FormWarPlane.cs | 36 +++- WarPlanes/WarPlanes/IDrawningObject.cs | 34 +++ WarPlanes/WarPlanes/Program.cs | 2 +- WarPlanes/WarPlanes/SimpleMap.cs | 50 +++++ WarPlanes/WarPlanes/СloseMap.cs | 43 ++++ 16 files changed, 820 insertions(+), 21 deletions(-) create mode 100644 WarPlanes/WarPlanes/AbstractMap.cs create mode 100644 WarPlanes/WarPlanes/DrawningFighter.cs create mode 100644 WarPlanes/WarPlanes/DrawningObject.cs create mode 100644 WarPlanes/WarPlanes/Fighter.cs create mode 100644 WarPlanes/WarPlanes/FormMap.Designer.cs create mode 100644 WarPlanes/WarPlanes/FormMap.cs create mode 100644 WarPlanes/WarPlanes/FormMap.resx create mode 100644 WarPlanes/WarPlanes/IDrawningObject.cs create mode 100644 WarPlanes/WarPlanes/SimpleMap.cs create mode 100644 WarPlanes/WarPlanes/СloseMap.cs diff --git a/WarPlanes/WarPlanes/AbstractMap.cs b/WarPlanes/WarPlanes/AbstractMap.cs new file mode 100644 index 0000000..bd9fd14 --- /dev/null +++ b/WarPlanes/WarPlanes/AbstractMap.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace WarPlanes +{ + internal abstract class AbstractMap + { + private IDrawningObject _drawningObject = null; + protected int[,] _map = null; + protected int _width; + protected int _height; + protected float _size_x; + protected float _size_y; + protected readonly Random _random = new(); + protected readonly int _freeRoad = 0; + protected readonly int _barrier = 1; + + public Bitmap CreateMap(int width, int height, IDrawningObject drawningObject) + { + _width = width; + _height = height; + _drawningObject = drawningObject; + GenerateMap(); + while (!SetObjectOnMap()) + { + GenerateMap(); + } + return DrawMapWithObject(); + } + public Bitmap MoveObject(Direction direction) + { + // TODO проверка, что объект может переместится в требуемом направлении + float xStep = 0; + float yStep = 0; + RectangleF rectObject = _drawningObject.GetCurrentPosition(); + + if (direction == Direction.Up) yStep = -_drawningObject.Step; + else if (direction == Direction.Down) yStep = +_drawningObject.Step; + else if (direction == Direction.Left) xStep = -_drawningObject.Step; + else if (direction == Direction.Right) xStep = _drawningObject.Step; + rectObject.X += xStep; + rectObject.Y += yStep; + if (isCollision(rectObject)) + { + _drawningObject.MoveObject(direction); + } + return DrawMapWithObject(); + } + private bool isCollision (RectangleF rectObject) + { + for (int i = (int) Math.Clamp((rectObject.Left / _size_x),0, _width); i < MathF.Ceiling(rectObject.Right / _size_x); i++) + { + for (int j = (int)Math.Clamp((rectObject.Top / _size_y),0,_height); j < MathF.Ceiling(rectObject.Bottom / _size_y); j++) + { + if (_map[i, j] == _barrier) + { + return false; + } + } + } + return true; + } + private bool SetObjectOnMap() + { + if (_drawningObject == null || _map == null) + { + return false; + } + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + _drawningObject.SetObject(x, y, _width, _height); + return isCollision(_drawningObject.GetCurrentPosition()); + } + private Bitmap DrawMapWithObject() + { + Bitmap bmp = new(_width, _height); + if (_drawningObject == null || _map == null) + { + return bmp; + } + Graphics gr = Graphics.FromImage(bmp); + for (int i = 0; i < _map.GetLength(0); ++i) + { + for (int j = 0; j < _map.GetLength(1); ++j) + { + if (_map[i, j] == _freeRoad) + { + DrawRoadPart(gr, i, j); + } + else if (_map[i, j] == _barrier) + { + DrawBarrierPart(gr, i, j); + } + } + } + _drawningObject.DrawningObject(gr); + return bmp; + } + + protected abstract void GenerateMap(); + protected abstract void DrawRoadPart(Graphics g, int i, int j); + protected abstract void DrawBarrierPart(Graphics g, int i, int j); + } +} \ No newline at end of file diff --git a/WarPlanes/WarPlanes/Direction.cs b/WarPlanes/WarPlanes/Direction.cs index 1352441..b4de59b 100644 --- a/WarPlanes/WarPlanes/Direction.cs +++ b/WarPlanes/WarPlanes/Direction.cs @@ -5,6 +5,7 @@ /// internal enum Direction { + None = 0, Up = 1, Down = 2, Left = 3, diff --git a/WarPlanes/WarPlanes/DrawningFighter.cs b/WarPlanes/WarPlanes/DrawningFighter.cs new file mode 100644 index 0000000..1aba474 --- /dev/null +++ b/WarPlanes/WarPlanes/DrawningFighter.cs @@ -0,0 +1,73 @@ +namespace WarPlanes +{ + internal class DrawningFighter : DrawningWarPlane + { + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес самолёта + /// Цвет самолёта + /// Дополнительный цвет + /// Признак наличия ракет + /// Признак наличия дополнительных крыльев + public DrawningFighter(int speed, float weight, Color bodyColor, Color dopColor, bool rocket, bool wing) : + base(speed, weight, bodyColor, 110, 60) + { + WarPlane = new EntityFighter(speed, weight, bodyColor, dopColor, rocket, wing); + } + public override void DrawTransport(Graphics g) + { + if (WarPlane is not EntityFighter Fighter) + { + return; + } + + Pen pen = new(Color.Black); + Brush dopBrush = new SolidBrush(Fighter.DopColor); + + if (Fighter.Rocket) + { + _startPosX -= 10; + _startPosY -= 5; + PointF[] point = new PointF[3]; + //нижняя ракета + point[0] = new PointF(_startPosX + _warplaneWidth / 2, _startPosY + _warplaneHeight); + point[1] = new PointF(_startPosX + _warplaneWidth / 2, _startPosY + _warplaneHeight + _warplaneHeight / 15); + point[2] = new PointF(_startPosX + _warplaneWidth / 2 - 5, _startPosY + _warplaneHeight + _warplaneHeight / 30); + g.FillPolygon(dopBrush, point); + point[0] = new PointF(_startPosX + _warplaneWidth*3 / 4-2 , _startPosY + _warplaneHeight -4); + point[1] = new PointF(_startPosX + _warplaneWidth*3 / 4-2, _startPosY + _warplaneHeight + _warplaneHeight / 15 + 4); + point[2] = new PointF(_startPosX + _warplaneWidth * 3 / 4 - 8, _startPosY + _warplaneHeight + _warplaneHeight / 30); + g.FillPolygon(dopBrush, point); + g.FillRectangle(dopBrush, _startPosX + _warplaneWidth / 2, _startPosY + _warplaneHeight, _warplaneWidth/4, _warplaneHeight/15); + + //верхняя ракета + point[0] = new PointF(_startPosX + _warplaneWidth / 2, _startPosY + _warplaneHeight / 15 + 1); + point[1] = new PointF(_startPosX + _warplaneWidth / 2, _startPosY + _warplaneHeight / 7.5F + 1); + point[2] = new PointF(_startPosX + _warplaneWidth / 2 - 5, _startPosY + _warplaneHeight / 11.25F +1); + g.FillPolygon(dopBrush, point); + point[0] = new PointF(_startPosX + _warplaneWidth * 3 / 4 - 2, _startPosY + _warplaneHeight / 15 -3); + point[1] = new PointF(_startPosX + _warplaneWidth * 3 / 4 - 2, _startPosY + _warplaneHeight / 7.5F + 5); + point[2] = new PointF(_startPosX + _warplaneWidth * 3 / 4 - 8, _startPosY + _warplaneHeight / 11.25F + 1 + _warplaneHeight / 30); + g.FillPolygon(dopBrush, point); + g.FillRectangle(dopBrush, _startPosX + _warplaneWidth / 2, _startPosY+ _warplaneHeight / 15+1, _warplaneWidth / 4, _warplaneHeight / 15); + _startPosX += 10; + _startPosY += 5; + } + + base.DrawTransport(g); + if (Fighter.Wing) + { + //Задние Крьлья + PointF[] point = new PointF[5]; + point[0] = new PointF(_startPosX + _warplaneWidth / 3, _startPosY + _warplaneHeight / 4); + point[1] = new PointF(_startPosX + _warplaneWidth / 3 + 5, _startPosY + _warplaneHeight / 4 ); + point[2] = new PointF(_startPosX + _warplaneWidth / 3 + 10, _startPosY + _warplaneHeight / 2); + point[3] = new PointF(_startPosX + _warplaneWidth / 3 + 5, _startPosY + _warplaneHeight - _warplaneHeight / 4); + point[4] = new PointF(_startPosX + _warplaneWidth / 3, _startPosY + _warplaneHeight - _warplaneHeight / 4); + g.FillPolygon(dopBrush, point); + } + } + } +} diff --git a/WarPlanes/WarPlanes/DrawningObject.cs b/WarPlanes/WarPlanes/DrawningObject.cs new file mode 100644 index 0000000..ea25915 --- /dev/null +++ b/WarPlanes/WarPlanes/DrawningObject.cs @@ -0,0 +1,35 @@ +namespace WarPlanes +{ + internal class DrawningObject : IDrawningObject + { + private DrawningWarPlane _warplane = null; + + public DrawningObject(DrawningWarPlane warplane) + { + _warplane = warplane; + } + + public float Step => _warplane?.WarPlane?.Step ?? 0; + + public RectangleF GetCurrentPosition() + { + return _warplane?.GetCurrentPosition() ?? default; + } + + public void MoveObject(Direction direction) + { + _warplane?.MoveTransport(direction); + } + + public void SetObject(int x, int y, int width, int height) + { + _warplane.SetPosition(x, y, width, height); + } + + void IDrawningObject.DrawningObject(Graphics g) + { + _warplane.DrawTransport(g); + // TODO + } + } +} \ No newline at end of file diff --git a/WarPlanes/WarPlanes/DrawningWarplane.cs b/WarPlanes/WarPlanes/DrawningWarplane.cs index e1c0ce4..1df3879 100644 --- a/WarPlanes/WarPlanes/DrawningWarplane.cs +++ b/WarPlanes/WarPlanes/DrawningWarplane.cs @@ -8,41 +8,54 @@ /// /// Класс-сущность /// - public EntityWarPlane WarPlane { get; private set; } + public EntityWarPlane WarPlane { get; protected set; } /// /// Левая координата отрисовки Военного самолёта /// - private float _startPosX; + protected float _startPosX; /// /// Верхняя кооридната отрисовки Военного самолёта /// - private float _startPosY; + protected float _startPosY; /// /// Ширина окна отрисовки /// - private int? _pictureWidth = null; + protected int? _pictureWidth = null; /// /// Высота окна отрисовки /// - private int? _pictureHeight = null; + protected int? _pictureHeight = null; /// /// Ширина отрисовки Военного самолёта /// - private readonly int _warplaneWidth = 80; + protected readonly int _warplaneWidth = 80; /// /// Высота отрисовки Военного самолёта /// - private readonly int _warplaneHeight = 50; + protected readonly int _warplaneHeight = 50; /// /// Инициализация свойств /// /// Скорость /// Вес Военного самолёта /// Цвет Военного самолёта - public void Init(int speed, float weight, Color bodyColor) + public DrawningWarPlane(int speed, float weight, Color bodyColor) { - WarPlane = new EntityWarPlane(); - WarPlane.Init(speed, weight, bodyColor); + WarPlane = new EntityWarPlane(speed, weight, bodyColor); + } + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес самолёта + /// Цвет кузова + /// Ширина отрисовки самолёта + /// Высота отрисовки самолёта + protected DrawningWarPlane(int speed, float weight, Color bodyColor, int warplaneWidth, int warplaneHeight) : + this(speed, weight, bodyColor) + { + _warplaneWidth = warplaneWidth; + _warplaneHeight = warplaneHeight; } /// /// Установка позиции Военного самолёта @@ -110,7 +123,7 @@ /// Отрисовка самолёта /// /// - public void DrawTransport(Graphics g) + public virtual void DrawTransport(Graphics g) { if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue) @@ -175,5 +188,13 @@ _startPosY = _pictureHeight.Value - _warplaneHeight; } } + /// + /// Получение текущей позиции объекта + /// + /// + public RectangleF GetCurrentPosition() + { + return new RectangleF(_startPosX, _startPosY, _warplaneWidth, _warplaneHeight); + } } } \ No newline at end of file diff --git a/WarPlanes/WarPlanes/EntityWarplane.cs b/WarPlanes/WarPlanes/EntityWarplane.cs index 38dd8f9..c882ddb 100644 --- a/WarPlanes/WarPlanes/EntityWarplane.cs +++ b/WarPlanes/WarPlanes/EntityWarplane.cs @@ -28,7 +28,7 @@ /// /// /// - public void Init(int speed, float weight, Color bodyColor) + public EntityWarPlane(int speed, float weight, Color bodyColor) { Random rnd = new(); Speed = speed <= 0 ? rnd.Next(50, 150) : speed; diff --git a/WarPlanes/WarPlanes/Fighter.cs b/WarPlanes/WarPlanes/Fighter.cs new file mode 100644 index 0000000..3f0b316 --- /dev/null +++ b/WarPlanes/WarPlanes/Fighter.cs @@ -0,0 +1,37 @@ +namespace WarPlanes +{ + /// + /// Класс-сущность "Истрибитель" + /// + internal class EntityFighter : EntityWarPlane + { + /// + /// Дополнительный цвет + /// + public Color DopColor { get; private set; } + /// + /// Признак наличия рокет + /// + public bool Rocket { get; private set; } + /// + /// Признак дополнительных крыльев + /// + public bool Wing { get; private set; } + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес самолёта + /// Цвет самолёта + /// Дополнительный цвет + /// Признак наличия ракет + /// Признак наличия дополнительных крыльев + public EntityFighter(int speed, float weight, Color bodyColor, Color dopColor, bool rocket, bool wing) : + base(speed, weight, bodyColor) + { + DopColor = dopColor; + Rocket = rocket; + Wing = wing; + } + } +} diff --git a/WarPlanes/WarPlanes/FormMap.Designer.cs b/WarPlanes/WarPlanes/FormMap.Designer.cs new file mode 100644 index 0000000..e33c32d --- /dev/null +++ b/WarPlanes/WarPlanes/FormMap.Designer.cs @@ -0,0 +1,207 @@ +namespace WarPlanes +{ + partial class FormMap + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.pictureBoxWarPlane = 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(); + this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.buttonCreate = new System.Windows.Forms.Button(); + this.buttonUp = new System.Windows.Forms.Button(); + this.buttonLeft = new System.Windows.Forms.Button(); + this.buttonRight = new System.Windows.Forms.Button(); + 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.pictureBoxWarPlane)).BeginInit(); + this.statusStrip.SuspendLayout(); + this.SuspendLayout(); + // + // pictureBoxCar + // + this.pictureBoxWarPlane.Dock = System.Windows.Forms.DockStyle.Fill; + this.pictureBoxWarPlane.Location = new System.Drawing.Point(0, 0); + this.pictureBoxWarPlane.Name = "pictureBoxCar"; + this.pictureBoxWarPlane.Size = new System.Drawing.Size(800, 428); + this.pictureBoxWarPlane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; + this.pictureBoxWarPlane.TabIndex = 0; + this.pictureBoxWarPlane.TabStop = false; + // + // statusStrip + // + this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripStatusLabelSpeed, + this.toolStripStatusLabelWeight, + this.toolStripStatusLabelBodyColor}); + this.statusStrip.Location = new System.Drawing.Point(0, 428); + this.statusStrip.Name = "statusStrip"; + this.statusStrip.Size = new System.Drawing.Size(800, 22); + this.statusStrip.TabIndex = 1; + // + // toolStripStatusLabelSpeed + // + this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed"; + this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17); + this.toolStripStatusLabelSpeed.Text = "Скорость:"; + // + // toolStripStatusLabelWeight + // + this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight"; + this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17); + this.toolStripStatusLabelWeight.Text = "Вес:"; + // + // toolStripStatusLabelBodyColor + // + this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor"; + this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); + this.toolStripStatusLabelBodyColor.Text = "Цвет:"; + // + // buttonCreate + // + this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonCreate.Location = new System.Drawing.Point(12, 390); + this.buttonCreate.Name = "buttonCreate"; + this.buttonCreate.Size = new System.Drawing.Size(75, 23); + this.buttonCreate.TabIndex = 2; + this.buttonCreate.Text = "Создать"; + this.buttonCreate.UseVisualStyleBackColor = true; + this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click); + // + // buttonUp + // + this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonUp.BackgroundImage = global::WarPlanes.Properties.Resources.arrowUp; + this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonUp.Location = new System.Drawing.Point(722, 350); + this.buttonUp.Name = "buttonUp"; + this.buttonUp.Size = new System.Drawing.Size(30, 30); + this.buttonUp.TabIndex = 3; + this.buttonUp.UseVisualStyleBackColor = true; + this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonLeft + // + this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonLeft.BackgroundImage = global::WarPlanes.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonLeft.Location = new System.Drawing.Point(686, 386); + this.buttonLeft.Name = "buttonLeft"; + this.buttonLeft.Size = new System.Drawing.Size(30, 30); + this.buttonLeft.TabIndex = 4; + this.buttonLeft.UseVisualStyleBackColor = true; + this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonRight + // + this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonRight.BackgroundImage = global::WarPlanes.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonRight.Location = new System.Drawing.Point(758, 386); + this.buttonRight.Name = "buttonRight"; + this.buttonRight.Size = new System.Drawing.Size(30, 30); + this.buttonRight.TabIndex = 5; + this.buttonRight.UseVisualStyleBackColor = true; + this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click); + // + // buttonDown + // + this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonDown.BackgroundImage = global::WarPlanes.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; + this.buttonDown.Location = new System.Drawing.Point(722, 386); + this.buttonDown.Name = "buttonDown"; + this.buttonDown.Size = new System.Drawing.Size(30, 30); + this.buttonDown.TabIndex = 6; + this.buttonDown.UseVisualStyleBackColor = true; + this.buttonDown.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(104, 390); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(110, 23); + this.buttonCreateModif.TabIndex = 7; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // + // comboBoxSelectorMap + // + this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxSelectorMap.FormattingEnabled = true; + this.comboBoxSelectorMap.Items.AddRange(new object[] { + "Простая карта", "Закрытая карта"}); + this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12); + this.comboBoxSelectorMap.Name = "comboBoxSelectorMap"; + this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23); + this.comboBoxSelectorMap.TabIndex = 8; + this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged); + // + // FormMap + // + 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.comboBoxSelectorMap); + this.Controls.Add(this.buttonCreateModif); + this.Controls.Add(this.buttonDown); + this.Controls.Add(this.buttonRight); + this.Controls.Add(this.buttonLeft); + this.Controls.Add(this.buttonUp); + this.Controls.Add(this.buttonCreate); + this.Controls.Add(this.pictureBoxWarPlane); + this.Controls.Add(this.statusStrip); + this.Name = "FormMap"; + this.Text = "Карта"; + ((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarPlane)).EndInit(); + this.statusStrip.ResumeLayout(false); + this.statusStrip.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private PictureBox pictureBoxWarPlane; + private StatusStrip statusStrip; + private ToolStripStatusLabel toolStripStatusLabelSpeed; + private ToolStripStatusLabel toolStripStatusLabelWeight; + private ToolStripStatusLabel toolStripStatusLabelBodyColor; + private Button buttonCreate; + private Button buttonUp; + private Button buttonLeft; + private Button buttonRight; + private Button buttonDown; + private Button buttonCreateModif; + private ComboBox comboBoxSelectorMap; + } +} \ No newline at end of file diff --git a/WarPlanes/WarPlanes/FormMap.cs b/WarPlanes/WarPlanes/FormMap.cs new file mode 100644 index 0000000..22e85bc --- /dev/null +++ b/WarPlanes/WarPlanes/FormMap.cs @@ -0,0 +1,93 @@ +namespace WarPlanes +{ + public partial class FormMap : Form + { + private AbstractMap _abstractMap; + + public FormMap() + { + InitializeComponent(); + _abstractMap = new SimpleMap(); + } + /// + /// Заполнение информации по объекту + /// + /// + private void SetData(DrawningWarPlane warplane) + { + toolStripStatusLabelSpeed.Text = $"Скорость: {warplane.WarPlane.Speed}"; + toolStripStatusLabelWeight.Text = $"Вес: {warplane.WarPlane.Weight}"; + toolStripStatusLabelBodyColor.Text = $"Цвет: {warplane.WarPlane.BodyColor.Name}"; + pictureBoxWarPlane.Image = _abstractMap.CreateMap(pictureBoxWarPlane.Width, pictureBoxWarPlane.Height, new DrawningObject(warplane)); + } + /// + /// Обработка нажатия кнопки "Создать" + /// + /// + /// + private void ButtonCreate_Click(object sender, EventArgs e) + { + Random rnd = new(); + var warplane = new DrawningWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(warplane); + } + /// + /// Изменение размеров формы + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + //получаем имя кнопки + string name = ((Button)sender)?.Name ?? string.Empty; + Direction dir = Direction.None; + switch (name) + { + case "buttonUp": + dir = Direction.Up; + break; + case "buttonDown": + dir = Direction.Down; + break; + case "buttonLeft": + dir = Direction.Left; + break; + case "buttonRight": + dir = Direction.Right; + break; + } + pictureBoxWarPlane.Image = _abstractMap?.MoveObject(dir); + } + /// + /// Обработка нажатия кнопки "Модификация" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + var fighter = new DrawningFighter(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(fighter); + } + /// + /// Смена карты + /// + /// + /// + private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) + { + switch (comboBoxSelectorMap.Text) + { + case "Простая карта": + _abstractMap = new SimpleMap(); + break; + case "Закрытая карта": + _abstractMap = new CloseMap(); + break; + } + } + } +} diff --git a/WarPlanes/WarPlanes/FormMap.resx b/WarPlanes/WarPlanes/FormMap.resx new file mode 100644 index 0000000..2c0949d --- /dev/null +++ b/WarPlanes/WarPlanes/FormMap.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs index 9f755bf..ba706b3 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs @@ -38,6 +38,7 @@ this.toolStripStatusLabelSpeed = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelWeight = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabelBodyColor = new System.Windows.Forms.ToolStripStatusLabel(); + this.buttonCreateModif = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.pictureBoxWarPlane)).BeginInit(); this.statusStrip.SuspendLayout(); this.SuspendLayout(); @@ -110,7 +111,7 @@ this.pictureBoxWarPlane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxWarPlane.TabIndex = 7; this.pictureBoxWarPlane.TabStop = false; - this.pictureBoxWarPlane.SizeChanged += new System.EventHandler(this.PictureBoxWarPlane_Resize); + this.pictureBoxWarPlane.SizeChanged += new System.EventHandler(this.PictureBoxCar_Resize); // // statusStrip // @@ -141,11 +142,22 @@ this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(36, 17); this.toolStripStatusLabelBodyColor.Text = "Цвет:"; // + // buttonCreateModif + // + this.buttonCreateModif.Location = new System.Drawing.Point(104, 390); + this.buttonCreateModif.Name = "buttonCreateModif"; + this.buttonCreateModif.Size = new System.Drawing.Size(110, 23); + this.buttonCreateModif.TabIndex = 14; + this.buttonCreateModif.Text = "Модификация"; + this.buttonCreateModif.UseVisualStyleBackColor = true; + this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click); + // // FormWarPlane // 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.buttonDown); this.Controls.Add(this.buttonRight); this.Controls.Add(this.buttonLeft); @@ -175,5 +187,6 @@ private ToolStripStatusLabel toolStripStatusLabelSpeed; private ToolStripStatusLabel toolStripStatusLabelWeight; private ToolStripStatusLabel toolStripStatusLabelBodyColor; + private Button buttonCreateModif; } } \ No newline at end of file diff --git a/WarPlanes/WarPlanes/FormWarPlane.cs b/WarPlanes/WarPlanes/FormWarPlane.cs index b67518c..2348ab7 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.cs @@ -19,6 +19,17 @@ namespace WarPlanes pictureBoxWarPlane.Image = bmp; } /// + /// + /// + private void SetData() + { + Random rnd = new(); + _warplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarPlane.Width, pictureBoxWarPlane.Height); + toolStripStatusLabelSpeed.Text = $": {_warplane.WarPlane.Speed}"; + toolStripStatusLabelWeight.Text = $": {_warplane.WarPlane.Weight}"; + toolStripStatusLabelBodyColor.Text = $": {_warplane.WarPlane.BodyColor.Name}"; + } + /// /// "" /// /// @@ -26,12 +37,8 @@ namespace WarPlanes private void ButtonCreate_Click(object sender, EventArgs e) { Random rnd = new(); - _warplane = new DrawningWarPlane(); - _warplane.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); - _warplane.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxWarPlane.Width, pictureBoxWarPlane.Height); - toolStripStatusLabelSpeed.Text = $": {_warplane.WarPlane.Speed}"; - toolStripStatusLabelWeight.Text = $": {_warplane.WarPlane.Weight}"; - toolStripStatusLabelBodyColor.Text = $": {_warplane.WarPlane.BodyColor.Name}"; + _warplane = new DrawningWarPlane(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256))); + SetData(); Draw(); } /// @@ -65,10 +72,25 @@ namespace WarPlanes /// /// /// - private void PictureBoxWarPlane_Resize(object sender, EventArgs e) + private void PictureBoxCar_Resize(object sender, EventArgs e) { _warplane?.ChangeBorders(pictureBoxWarPlane.Width, pictureBoxWarPlane.Height); Draw(); } + /// + /// "" + /// + /// + /// + private void ButtonCreateModif_Click(object sender, EventArgs e) + { + Random rnd = new(); + _warplane = new DrawningFighter(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(); + Draw(); + } } } \ No newline at end of file diff --git a/WarPlanes/WarPlanes/IDrawningObject.cs b/WarPlanes/WarPlanes/IDrawningObject.cs new file mode 100644 index 0000000..8002336 --- /dev/null +++ b/WarPlanes/WarPlanes/IDrawningObject.cs @@ -0,0 +1,34 @@ +namespace WarPlanes +{ + internal interface IDrawningObject + { + /// + /// Шаг перемещения объекта + /// + public float Step { get; } + /// + /// Установка позиции объекта + /// + /// Координата X + /// Координата Y + /// Ширина полотна + /// Высота полотна + void SetObject(int x, int y, int width, int height); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + /// + void MoveObject(Direction direction); + /// + /// Отрисовка объекта + /// + /// + void DrawningObject(Graphics g); + /// + /// Получение текущей позиции объекта + /// + /// + RectangleF GetCurrentPosition(); + } +} \ No newline at end of file diff --git a/WarPlanes/WarPlanes/Program.cs b/WarPlanes/WarPlanes/Program.cs index 86414fc..21241cc 100644 --- a/WarPlanes/WarPlanes/Program.cs +++ b/WarPlanes/WarPlanes/Program.cs @@ -11,7 +11,7 @@ namespace WarPlanes // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormWarPlane()); + Application.Run(new FormMap()); } } } \ No newline at end of file diff --git a/WarPlanes/WarPlanes/SimpleMap.cs b/WarPlanes/WarPlanes/SimpleMap.cs new file mode 100644 index 0000000..1e26bca --- /dev/null +++ b/WarPlanes/WarPlanes/SimpleMap.cs @@ -0,0 +1,50 @@ +namespace WarPlanes +{ + /// + /// Простая реализация абсрактного класса AbstractMap + /// + internal class SimpleMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Black); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.Gray); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + 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, _size_x, _size_y); + } + 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 < 50) + { + int x = _random.Next(0, 100); + int y = _random.Next(0, 100); + if (_map[x, y] == _freeRoad) + { + _map[x, y] = _barrier; + counter++; + } + } + } + } +} \ No newline at end of file diff --git a/WarPlanes/WarPlanes/СloseMap.cs b/WarPlanes/WarPlanes/СloseMap.cs new file mode 100644 index 0000000..fef90cc --- /dev/null +++ b/WarPlanes/WarPlanes/СloseMap.cs @@ -0,0 +1,43 @@ +namespace WarPlanes +{ + /// + /// Простая реализация абсрактного класса AbstractMap + /// + internal class CloseMap : AbstractMap + { + /// + /// Цвет участка закрытого + /// + private readonly Brush barrierColor = new SolidBrush(Color.Red); + /// + /// Цвет участка открытого + /// + private readonly Brush roadColor = new SolidBrush(Color.WhiteSmoke); + + protected override void DrawBarrierPart(Graphics g, int i, int j) + { + 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, _size_x, _size_y); + } + protected override void GenerateMap() + { + _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 j = 0; j < _map.GetLength(1); ++j) + { + if (i == 0 || j == 0 || i == _map.GetLength(0) - 1 || j == _map.GetLength(1) - 1) + _map[i, j] = _barrier; + else + _map[i, j] = _freeRoad; + } + } + + } + } +} \ No newline at end of file From c63c420f7e7edb1642c8d729d70c8cd5fd52fe17 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Tue, 4 Oct 2022 21:15:19 +0400 Subject: [PATCH 2/8] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/FormMap.Designer.cs | 4 ++-- WarPlanes/WarPlanes/FormWarPlane.Designer.cs | 2 +- WarPlanes/WarPlanes/FormWarPlane.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/WarPlanes/WarPlanes/FormMap.Designer.cs b/WarPlanes/WarPlanes/FormMap.Designer.cs index e33c32d..0995a6e 100644 --- a/WarPlanes/WarPlanes/FormMap.Designer.cs +++ b/WarPlanes/WarPlanes/FormMap.Designer.cs @@ -44,11 +44,11 @@ this.statusStrip.SuspendLayout(); this.SuspendLayout(); // - // pictureBoxCar + // pictureBoxWarPlane // this.pictureBoxWarPlane.Dock = System.Windows.Forms.DockStyle.Fill; this.pictureBoxWarPlane.Location = new System.Drawing.Point(0, 0); - this.pictureBoxWarPlane.Name = "pictureBoxCar"; + this.pictureBoxWarPlane.Name = "pictureBoxWarPlane"; this.pictureBoxWarPlane.Size = new System.Drawing.Size(800, 428); this.pictureBoxWarPlane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxWarPlane.TabIndex = 0; diff --git a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs index ba706b3..068fbf7 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs @@ -111,7 +111,7 @@ this.pictureBoxWarPlane.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; this.pictureBoxWarPlane.TabIndex = 7; this.pictureBoxWarPlane.TabStop = false; - this.pictureBoxWarPlane.SizeChanged += new System.EventHandler(this.PictureBoxCar_Resize); + this.pictureBoxWarPlane.SizeChanged += new System.EventHandler(this.PictureBoxWarPlane_Resize); // // statusStrip // diff --git a/WarPlanes/WarPlanes/FormWarPlane.cs b/WarPlanes/WarPlanes/FormWarPlane.cs index 2348ab7..d1de930 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.cs @@ -72,7 +72,7 @@ namespace WarPlanes /// /// /// - private void PictureBoxCar_Resize(object sender, EventArgs e) + private void PictureBoxWarPlane_Resize(object sender, EventArgs e) { _warplane?.ChangeBorders(pictureBoxWarPlane.Width, pictureBoxWarPlane.Height); Draw(); From 10a75c38fc7d4167d09c3fda5bef7b0872ceaef1 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Wed, 5 Oct 2022 00:52:02 +0400 Subject: [PATCH 3/8] =?UTF-8?q?=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=B8=20=D0=B2=20SetPosition?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/DrawningWarplane.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/WarPlanes/WarPlanes/DrawningWarplane.cs b/WarPlanes/WarPlanes/DrawningWarplane.cs index 1df3879..5cf40f0 100644 --- a/WarPlanes/WarPlanes/DrawningWarplane.cs +++ b/WarPlanes/WarPlanes/DrawningWarplane.cs @@ -66,16 +66,16 @@ /// Высота картинки public void SetPosition(int x, int y, int width, int height) { - _startPosX = x; - _startPosY = y; - _pictureWidth = width; - _pictureHeight = height; - - if (width <= _warplaneWidth || height <= _warplaneHeight || x < 0 || y < 0 || x > width - _warplaneWidth || y > height - _warplaneHeight) + if (width <= _warplaneWidth || height <= _warplaneHeight || x < 0 || y < 0 || x > width - _warplaneWidth || y > height - _warplaneHeight) { _pictureWidth = null; _pictureHeight = null; - } + return; + } + _startPosX = x; + _startPosY = y; + _pictureWidth = width; + _pictureHeight = height; } /// /// Изменение направления пермещения From 9e57fd3aeb2b06bfcbb50d5e7da39decaf5b2b14 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Thu, 13 Oct 2022 14:36:02 +0400 Subject: [PATCH 4/8] =?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=B2=D1=8B=D1=85=D0=BE=D0=B4=D0=B0?= =?UTF-8?q?=20=D0=B7=D0=B0=20=D0=B3=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20?= =?UTF-8?q?=D0=BC=D0=B0=D1=81=D1=81=D0=B8=D0=B2=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/AbstractMap.cs | 18 +++++++++--------- WarPlanes/WarPlanes/DrawningObject.cs | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/WarPlanes/WarPlanes/AbstractMap.cs b/WarPlanes/WarPlanes/AbstractMap.cs index bd9fd14..a9a4765 100644 --- a/WarPlanes/WarPlanes/AbstractMap.cs +++ b/WarPlanes/WarPlanes/AbstractMap.cs @@ -32,17 +32,17 @@ namespace WarPlanes } public Bitmap MoveObject(Direction direction) { - // TODO проверка, что объект может переместится в требуемом направлении - float xStep = 0; - float yStep = 0; RectangleF rectObject = _drawningObject.GetCurrentPosition(); - if (direction == Direction.Up) yStep = -_drawningObject.Step; - else if (direction == Direction.Down) yStep = +_drawningObject.Step; - else if (direction == Direction.Left) xStep = -_drawningObject.Step; - else if (direction == Direction.Right) xStep = _drawningObject.Step; - rectObject.X += xStep; - rectObject.Y += yStep; + if (direction == Direction.Up) rectObject.Y -= _drawningObject.Step; + else if (direction == Direction.Down) rectObject.Y += _drawningObject.Step; + else if (direction == Direction.Left) rectObject.X -= _drawningObject.Step; + else if (direction == Direction.Right) rectObject.X += _drawningObject.Step; + + if(rectObject.X < 0 || rectObject.Right >= _width || rectObject.Y < 0 || rectObject.Bottom >= _height) + { + return DrawMapWithObject(); + } if (isCollision(rectObject)) { _drawningObject.MoveObject(direction); diff --git a/WarPlanes/WarPlanes/DrawningObject.cs b/WarPlanes/WarPlanes/DrawningObject.cs index ea25915..b2253d8 100644 --- a/WarPlanes/WarPlanes/DrawningObject.cs +++ b/WarPlanes/WarPlanes/DrawningObject.cs @@ -29,7 +29,6 @@ void IDrawningObject.DrawningObject(Graphics g) { _warplane.DrawTransport(g); - // TODO } } } \ No newline at end of file From 36d0e531687525a6263c58fc5a4839b490f546a2 Mon Sep 17 00:00:00 2001 From: 1maksim1 Date: Thu, 13 Oct 2022 21:43:25 +0400 Subject: [PATCH 5/8] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'WarPlanes/WarPlanes/DrawningWarPlane.?= =?UTF-8?q?cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/{DrawningWarplane.cs => DrawningWarPlane.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename WarPlanes/WarPlanes/{DrawningWarplane.cs => DrawningWarPlane.cs} (100%) diff --git a/WarPlanes/WarPlanes/DrawningWarplane.cs b/WarPlanes/WarPlanes/DrawningWarPlane.cs similarity index 100% rename from WarPlanes/WarPlanes/DrawningWarplane.cs rename to WarPlanes/WarPlanes/DrawningWarPlane.cs From 8127c1cc38a14e1c9c762f0ead175b0d053e9dd7 Mon Sep 17 00:00:00 2001 From: 1maksim1 Date: Thu, 13 Oct 2022 21:43:42 +0400 Subject: [PATCH 6/8] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D0=BB(?= =?UTF-8?q?=D0=B0)=20=D0=BD=D0=B0=20'WarPlanes/WarPlanes/EntityWarPlane.cs?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/WarPlanes/{EntityWarplane.cs => EntityWarPlane.cs} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename WarPlanes/WarPlanes/{EntityWarplane.cs => EntityWarPlane.cs} (100%) diff --git a/WarPlanes/WarPlanes/EntityWarplane.cs b/WarPlanes/WarPlanes/EntityWarPlane.cs similarity index 100% rename from WarPlanes/WarPlanes/EntityWarplane.cs rename to WarPlanes/WarPlanes/EntityWarPlane.cs From 9a87009db15cab98c7f3ca60c386ee26a27a9640 Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Thu, 13 Oct 2022 22:45:34 +0400 Subject: [PATCH 7/8] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D1=81=D1=81=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{DrawningObject.cs => DrawningObjectWarPlane.cs} | 4 ++-- WarPlanes/WarPlanes/{Fighter.cs => EntityFighter.cs} | 0 WarPlanes/WarPlanes/FormMap.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename WarPlanes/WarPlanes/{DrawningObject.cs => DrawningObjectWarPlane.cs} (85%) rename WarPlanes/WarPlanes/{Fighter.cs => EntityFighter.cs} (100%) diff --git a/WarPlanes/WarPlanes/DrawningObject.cs b/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs similarity index 85% rename from WarPlanes/WarPlanes/DrawningObject.cs rename to WarPlanes/WarPlanes/DrawningObjectWarPlane.cs index b2253d8..6af1850 100644 --- a/WarPlanes/WarPlanes/DrawningObject.cs +++ b/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs @@ -1,10 +1,10 @@ namespace WarPlanes { - internal class DrawningObject : IDrawningObject + internal class DrawningObjectWarPlane : IDrawningObject { private DrawningWarPlane _warplane = null; - public DrawningObject(DrawningWarPlane warplane) + public DrawningObjectWarPlane(DrawningWarPlane warplane) { _warplane = warplane; } diff --git a/WarPlanes/WarPlanes/Fighter.cs b/WarPlanes/WarPlanes/EntityFighter.cs similarity index 100% rename from WarPlanes/WarPlanes/Fighter.cs rename to WarPlanes/WarPlanes/EntityFighter.cs diff --git a/WarPlanes/WarPlanes/FormMap.cs b/WarPlanes/WarPlanes/FormMap.cs index 22e85bc..b19dd9a 100644 --- a/WarPlanes/WarPlanes/FormMap.cs +++ b/WarPlanes/WarPlanes/FormMap.cs @@ -18,7 +18,7 @@ toolStripStatusLabelSpeed.Text = $"Скорость: {warplane.WarPlane.Speed}"; toolStripStatusLabelWeight.Text = $"Вес: {warplane.WarPlane.Weight}"; toolStripStatusLabelBodyColor.Text = $"Цвет: {warplane.WarPlane.BodyColor.Name}"; - pictureBoxWarPlane.Image = _abstractMap.CreateMap(pictureBoxWarPlane.Width, pictureBoxWarPlane.Height, new DrawningObject(warplane)); + pictureBoxWarPlane.Image = _abstractMap.CreateMap(pictureBoxWarPlane.Width, pictureBoxWarPlane.Height, new DrawningObjectWarPlane(warplane)); } /// /// Обработка нажатия кнопки "Создать" From 2db962f8607da543af9acb92937577ffc30492bc Mon Sep 17 00:00:00 2001 From: m1aksim1 Date: Fri, 14 Oct 2022 13:33:18 +0400 Subject: [PATCH 8/8] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=B8?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarPlanes/{WarPlanes.sln => AirFighter.sln} | 2 +- WarPlanes/WarPlanes/AbstractMap.cs | 2 +- .../WarPlanes/{WarPlanes.csproj => AirFighter.csproj} | 0 WarPlanes/WarPlanes/Direction.cs | 2 +- WarPlanes/WarPlanes/DrawningFighter.cs | 2 +- WarPlanes/WarPlanes/DrawningObjectWarPlane.cs | 2 +- WarPlanes/WarPlanes/DrawningWarPlane.cs | 2 +- WarPlanes/WarPlanes/EntityFighter.cs | 2 +- WarPlanes/WarPlanes/EntityWarPlane.cs | 2 +- WarPlanes/WarPlanes/FormMap.Designer.cs | 10 +++++----- WarPlanes/WarPlanes/FormMap.cs | 2 +- WarPlanes/WarPlanes/FormWarPlane.Designer.cs | 10 +++++----- WarPlanes/WarPlanes/FormWarPlane.cs | 2 +- WarPlanes/WarPlanes/IDrawningObject.cs | 2 +- WarPlanes/WarPlanes/Program.cs | 2 +- WarPlanes/WarPlanes/Properties/Resources.Designer.cs | 4 ++-- WarPlanes/WarPlanes/SimpleMap.cs | 2 +- WarPlanes/WarPlanes/СloseMap.cs | 2 +- 18 files changed, 26 insertions(+), 26 deletions(-) rename WarPlanes/{WarPlanes.sln => AirFighter.sln} (87%) rename WarPlanes/WarPlanes/{WarPlanes.csproj => AirFighter.csproj} (100%) diff --git a/WarPlanes/WarPlanes.sln b/WarPlanes/AirFighter.sln similarity index 87% rename from WarPlanes/WarPlanes.sln rename to WarPlanes/AirFighter.sln index 48f9a9e..12efab8 100644 --- a/WarPlanes/WarPlanes.sln +++ b/WarPlanes/AirFighter.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.2.32526.322 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WarPlanes", "WarPlanes\WarPlanes.csproj", "{73B34668-A34C-4E60-8961-BFBAF2BCEE88}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AirFighter", "WarPlanes\AirFighter.csproj", "{73B34668-A34C-4E60-8961-BFBAF2BCEE88}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/WarPlanes/WarPlanes/AbstractMap.cs b/WarPlanes/WarPlanes/AbstractMap.cs index a9a4765..90f92b0 100644 --- a/WarPlanes/WarPlanes/AbstractMap.cs +++ b/WarPlanes/WarPlanes/AbstractMap.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace WarPlanes +namespace AirFighter { internal abstract class AbstractMap { diff --git a/WarPlanes/WarPlanes/WarPlanes.csproj b/WarPlanes/WarPlanes/AirFighter.csproj similarity index 100% rename from WarPlanes/WarPlanes/WarPlanes.csproj rename to WarPlanes/WarPlanes/AirFighter.csproj diff --git a/WarPlanes/WarPlanes/Direction.cs b/WarPlanes/WarPlanes/Direction.cs index b4de59b..b0777d9 100644 --- a/WarPlanes/WarPlanes/Direction.cs +++ b/WarPlanes/WarPlanes/Direction.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Направление перемещения diff --git a/WarPlanes/WarPlanes/DrawningFighter.cs b/WarPlanes/WarPlanes/DrawningFighter.cs index 1aba474..4974d15 100644 --- a/WarPlanes/WarPlanes/DrawningFighter.cs +++ b/WarPlanes/WarPlanes/DrawningFighter.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { internal class DrawningFighter : DrawningWarPlane { diff --git a/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs b/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs index 6af1850..c8e2c7d 100644 --- a/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs +++ b/WarPlanes/WarPlanes/DrawningObjectWarPlane.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { internal class DrawningObjectWarPlane : IDrawningObject { diff --git a/WarPlanes/WarPlanes/DrawningWarPlane.cs b/WarPlanes/WarPlanes/DrawningWarPlane.cs index 5cf40f0..3017cca 100644 --- a/WarPlanes/WarPlanes/DrawningWarPlane.cs +++ b/WarPlanes/WarPlanes/DrawningWarPlane.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности diff --git a/WarPlanes/WarPlanes/EntityFighter.cs b/WarPlanes/WarPlanes/EntityFighter.cs index 3f0b316..c77b46b 100644 --- a/WarPlanes/WarPlanes/EntityFighter.cs +++ b/WarPlanes/WarPlanes/EntityFighter.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Класс-сущность "Истрибитель" diff --git a/WarPlanes/WarPlanes/EntityWarPlane.cs b/WarPlanes/WarPlanes/EntityWarPlane.cs index c882ddb..f9823b0 100644 --- a/WarPlanes/WarPlanes/EntityWarPlane.cs +++ b/WarPlanes/WarPlanes/EntityWarPlane.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Класс-сущность "Военный самолёт" diff --git a/WarPlanes/WarPlanes/FormMap.Designer.cs b/WarPlanes/WarPlanes/FormMap.Designer.cs index 0995a6e..a2c54c1 100644 --- a/WarPlanes/WarPlanes/FormMap.Designer.cs +++ b/WarPlanes/WarPlanes/FormMap.Designer.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { partial class FormMap { @@ -97,7 +97,7 @@ // buttonUp // this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::WarPlanes.Properties.Resources.arrowUp; + this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.arrowUp; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.Location = new System.Drawing.Point(722, 350); this.buttonUp.Name = "buttonUp"; @@ -109,7 +109,7 @@ // buttonLeft // this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::WarPlanes.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.Location = new System.Drawing.Point(686, 386); this.buttonLeft.Name = "buttonLeft"; @@ -121,7 +121,7 @@ // buttonRight // this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::WarPlanes.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.Location = new System.Drawing.Point(758, 386); this.buttonRight.Name = "buttonRight"; @@ -133,7 +133,7 @@ // buttonDown // this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::WarPlanes.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.Location = new System.Drawing.Point(722, 386); this.buttonDown.Name = "buttonDown"; diff --git a/WarPlanes/WarPlanes/FormMap.cs b/WarPlanes/WarPlanes/FormMap.cs index b19dd9a..758f8b6 100644 --- a/WarPlanes/WarPlanes/FormMap.cs +++ b/WarPlanes/WarPlanes/FormMap.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { public partial class FormMap : Form { diff --git a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs index 068fbf7..1d258b2 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.Designer.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.Designer.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { partial class FormWarPlane { @@ -46,7 +46,7 @@ // buttonDown // this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonDown.BackgroundImage = global::WarPlanes.Properties.Resources.arrowDown; + this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.arrowDown; this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonDown.Location = new System.Drawing.Point(722, 386); this.buttonDown.Name = "buttonDown"; @@ -58,7 +58,7 @@ // buttonRight // this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRight.BackgroundImage = global::WarPlanes.Properties.Resources.arrowRight; + this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.arrowRight; this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonRight.Location = new System.Drawing.Point(758, 386); this.buttonRight.Name = "buttonRight"; @@ -70,7 +70,7 @@ // buttonLeft // this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonLeft.BackgroundImage = global::WarPlanes.Properties.Resources.arrowLeft; + this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.arrowLeft; this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonLeft.Location = new System.Drawing.Point(686, 386); this.buttonLeft.Name = "buttonLeft"; @@ -82,7 +82,7 @@ // buttonUp // this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonUp.BackgroundImage = global::WarPlanes.Properties.Resources.arrowUp; + this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.arrowUp; this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch; this.buttonUp.Location = new System.Drawing.Point(722, 350); this.buttonUp.Name = "buttonUp"; diff --git a/WarPlanes/WarPlanes/FormWarPlane.cs b/WarPlanes/WarPlanes/FormWarPlane.cs index d1de930..cdfd56f 100644 --- a/WarPlanes/WarPlanes/FormWarPlane.cs +++ b/WarPlanes/WarPlanes/FormWarPlane.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { public partial class FormWarPlane : Form { diff --git a/WarPlanes/WarPlanes/IDrawningObject.cs b/WarPlanes/WarPlanes/IDrawningObject.cs index 8002336..3d6457c 100644 --- a/WarPlanes/WarPlanes/IDrawningObject.cs +++ b/WarPlanes/WarPlanes/IDrawningObject.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { internal interface IDrawningObject { diff --git a/WarPlanes/WarPlanes/Program.cs b/WarPlanes/WarPlanes/Program.cs index 21241cc..b613151 100644 --- a/WarPlanes/WarPlanes/Program.cs +++ b/WarPlanes/WarPlanes/Program.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { internal static class Program { diff --git a/WarPlanes/WarPlanes/Properties/Resources.Designer.cs b/WarPlanes/WarPlanes/Properties/Resources.Designer.cs index bb2583b..657b5a0 100644 --- a/WarPlanes/WarPlanes/Properties/Resources.Designer.cs +++ b/WarPlanes/WarPlanes/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace WarPlanes.Properties { +namespace AirFighter.Properties { using System; @@ -39,7 +39,7 @@ namespace WarPlanes.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WarPlanes.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirFighter.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/WarPlanes/WarPlanes/SimpleMap.cs b/WarPlanes/WarPlanes/SimpleMap.cs index 1e26bca..7529e0c 100644 --- a/WarPlanes/WarPlanes/SimpleMap.cs +++ b/WarPlanes/WarPlanes/SimpleMap.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Простая реализация абсрактного класса AbstractMap diff --git a/WarPlanes/WarPlanes/СloseMap.cs b/WarPlanes/WarPlanes/СloseMap.cs index fef90cc..83e09b2 100644 --- a/WarPlanes/WarPlanes/СloseMap.cs +++ b/WarPlanes/WarPlanes/СloseMap.cs @@ -1,4 +1,4 @@ -namespace WarPlanes +namespace AirFighter { /// /// Простая реализация абсрактного класса AbstractMap