diff --git a/AirBomber/AirBomber/AirBomber.csproj b/AirBomber/AirBomber/AirBomber.csproj index b57c89e..13ee123 100644 --- a/AirBomber/AirBomber/AirBomber.csproj +++ b/AirBomber/AirBomber/AirBomber.csproj @@ -8,4 +8,19 @@ enable + + + True + True + Resources.resx + + + + + + ResXFileCodeGenerator + Resources.Designer.cs + + + \ No newline at end of file diff --git a/AirBomber/AirBomber/Direction.cs b/AirBomber/AirBomber/Direction.cs index eb271bc..3615f98 100644 --- a/AirBomber/AirBomber/Direction.cs +++ b/AirBomber/AirBomber/Direction.cs @@ -6,7 +6,11 @@ using System.Threading.Tasks; namespace AirBomber { - internal class Direction + public enum DirectionType { + Up = 1, + Down = 2, + Left = 3, + Right = 4 } } diff --git a/AirBomber/AirBomber/DrawningAirBomber.cs b/AirBomber/AirBomber/DrawningAirBomber.cs new file mode 100644 index 0000000..69c74da --- /dev/null +++ b/AirBomber/AirBomber/DrawningAirBomber.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AirBomber +{ + public class DrawningAirBomber + { + public EntityAirBomber? EntityAirBomber { get; private set; } + private int _pictureWidth; + private int _pictureHeight; + /// + /// Левая координата прорисовки бобмбардировщика + /// + private int _startPosX; + /// + /// Верхняя кооридната прорисовки бомбардировщика + /// + private int _startPosY; + /// + /// Ширина прорисовки бомбардировщика + /// + private readonly int _bomberWidth = 110; + /// + /// Высота прорисовки бомбардировщика + /// + private readonly int _bomberHeight = 60; + /// + /// Инициализация свойств + /// + /// Скорость + /// Вес + /// Цвет кузова + /// Дополнительный цвет + /// Признак наличия бомб + /// Признак наличия топливных баков + /// Ширина картинки + /// Высота картинки + /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах + public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bombs, bool fuelTanks, int width, int height) + { + // TODO: Продумать проверки + _pictureWidth = width; + _pictureHeight = height; + EntityAirBomber = new EntityAirBomber(); + EntityAirBomber.Init(speed, weight, bodyColor, additionalColor, bombs, fuelTanks); + return true; + } + /// + /// Установка позиции + /// + /// Координата X + /// Координата Y + public void SetPosition(int x, int y) + { + // TODO: Изменение x, y + _startPosX = x; + _startPosY = y; + } + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (EntityAirBomber == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX - EntityAirBomber.Step > 0) + { + _startPosX -= (int)EntityAirBomber.Step; + } + break; + //вверх + case DirectionType.Up: + if (_startPosY - EntityAirBomber.Step > 0) + { + _startPosY -= (int)EntityAirBomber.Step; + } + break; + // вправо + case DirectionType.Right: + // TODO: Продумать логику + break; + //вниз + case DirectionType.Down: + // TODO: Продумать логику + break; + } + } + /// + /// Прорисовка объекта + /// + /// + public void DrawTransport(Graphics g) + { + if (EntityAirBomber == null) + { + return; + } + Pen pen = new(Color.Black); + Brush additionalBrush = new + SolidBrush(EntityAirBomber.AdditionalColor); + // обвесы + if (EntityAirBomber.Bombs) + { + g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, + 20); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, + 20, 40); + g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, + 15); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, + 15, 15); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY, 20, 20); + g.FillEllipse(additionalBrush, _startPosX + 90, + _startPosY + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 10, 20, 40); + g.FillRectangle(additionalBrush, _startPosX + 90, _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 90, + _startPosY + 45, 15, 15); + g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20); + g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20); + g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, + 40); + g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, + 15); + g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, + 14, 15); + g.FillEllipse(additionalBrush, _startPosX, _startPosY, + 20, 20); + g.FillEllipse(additionalBrush, _startPosX, _startPosY + + 40, 20, 20); + g.FillRectangle(additionalBrush, _startPosX + 1, + _startPosY + 10, 25, 40); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 1, 15, 15); + g.FillRectangle(additionalBrush, _startPosX + 5, + _startPosY + 45, 15, 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, + 15); + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, + 39, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 1, 40, 15); + g.FillRectangle(additionalBrush, _startPosX + 35, + _startPosY + 45, 40, 15); + } + //границы автомобиля + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 10, _startPosY + 35, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 5, 20, 20); + g.DrawEllipse(pen, _startPosX + 80, _startPosY + 35, 20, 20); + g.DrawRectangle(pen, _startPosX + 9, _startPosY + 15, 10, 30); + g.DrawRectangle(pen, _startPosX + 90, _startPosY + 15, 10, + 30); + g.DrawRectangle(pen, _startPosX + 20, _startPosY + 4, 70, 52); + //задние фары + Brush brRed = new SolidBrush(Color.Red); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 5, 20, 20); + g.FillEllipse(brRed, _startPosX + 10, _startPosY + 35, 20, + 20); + //передние фары + Brush brYellow = new SolidBrush(Color.Yellow); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 5, 20, + 20); + g.FillEllipse(brYellow, _startPosX + 80, _startPosY + 35, 20, + 20); + //кузов + Brush br = new SolidBrush(EntityAirBomber.BodyColor); + g.FillRectangle(br, _startPosX + 10, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 90, _startPosY + 15, 10, 30); + g.FillRectangle(br, _startPosX + 20, _startPosY + 5, 70, 50); + //стекла + Brush brBlue = new SolidBrush(Color.LightBlue); + g.FillRectangle(brBlue, _startPosX + 70, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 30, _startPosY + 10, 5, + 40); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 8, 35, + 2); + g.FillRectangle(brBlue, _startPosX + 35, _startPosY + 51, 35, + 2); + //выделяем рамкой крышу + g.DrawRectangle(pen, _startPosX + 35, _startPosY + 10, 35, + 40); + g.DrawRectangle(pen, _startPosX + 75, _startPosY + 15, 25, + 30); + g.DrawRectangle(pen, _startPosX + 10, _startPosY + 15, 15, + 30); + // крыло + if (EntityAirBomber.FuelTanks) + { + g.FillRectangle(additionalBrush, _startPosX, _startPosY + + 5, 10, 50); + g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, + 50); + } + } + } +} diff --git a/AirBomber/AirBomber/EntityAirBomber.cs b/AirBomber/AirBomber/EntityAirBomber.cs index fa37724..a4907a1 100644 --- a/AirBomber/AirBomber/EntityAirBomber.cs +++ b/AirBomber/AirBomber/EntityAirBomber.cs @@ -24,16 +24,16 @@ namespace AirBomber /// Основной цвет /// Дополнительный цвет /// Признак наличия бомб - /// Признак наличия топливных баков + /// Признак наличия топливных баков public void Init(int speed, double weight, Color bodyColor, Color - additionalColor, bool bombs, bool fueltanks) + additionalColor, bool bombs, bool fuelTanks) { Speed = speed; Weight = weight; BodyColor = bodyColor; AdditionalColor = additionalColor; Bombs = bombs; - FuelTanks = fueltanks; + FuelTanks = fuelTanks; } } diff --git a/AirBomber/AirBomber/Form1.Designer.cs b/AirBomber/AirBomber/Form1.Designer.cs deleted file mode 100644 index 185eea6..0000000 --- a/AirBomber/AirBomber/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace AirBomber -{ - partial class Form1 - { - /// - /// 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.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} \ No newline at end of file diff --git a/AirBomber/AirBomber/FormAirBomber.Designer.cs b/AirBomber/AirBomber/FormAirBomber.Designer.cs new file mode 100644 index 0000000..6ad235b --- /dev/null +++ b/AirBomber/AirBomber/FormAirBomber.Designer.cs @@ -0,0 +1,115 @@ +namespace AirBomber +{ + partial class FormAirBomber + { + /// + /// 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() + { + buttonCreate = new Button(); + buttonDown = new Button(); + buttonLeft = new Button(); + buttonRight = new Button(); + buttonUp = new Button(); + SuspendLayout(); + // + // buttonCreate + // + buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreate.Location = new Point(29, 479); + buttonCreate.Name = "buttonCreate"; + buttonCreate.Size = new Size(148, 34); + buttonCreate.TabIndex = 0; + buttonCreate.Text = "Создать"; + buttonCreate.UseVisualStyleBackColor = true; + // + // buttonDown + // + buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonDown.BackgroundImage = Properties.Resources.arrowDown; + buttonDown.BackgroundImageLayout = ImageLayout.Zoom; + buttonDown.Location = new Point(842, 483); + buttonDown.Name = "buttonDown"; + buttonDown.Size = new Size(30, 30); + buttonDown.TabIndex = 1; + buttonDown.UseVisualStyleBackColor = true; + // + // buttonLeft + // + buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonLeft.BackgroundImage = Properties.Resources.arrowLeft; + buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; + buttonLeft.Location = new Point(806, 483); + buttonLeft.Name = "buttonLeft"; + buttonLeft.Size = new Size(30, 30); + buttonLeft.TabIndex = 2; + buttonLeft.UseVisualStyleBackColor = true; + // + // buttonRight + // + buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonRight.BackgroundImage = Properties.Resources.arrowRight; + buttonRight.BackgroundImageLayout = ImageLayout.Zoom; + buttonRight.Location = new Point(878, 483); + buttonRight.Name = "buttonRight"; + buttonRight.Size = new Size(30, 30); + buttonRight.TabIndex = 3; + buttonRight.UseVisualStyleBackColor = true; + // + // buttonUp + // + buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; + buttonUp.BackgroundImage = Properties.Resources.arrowUp; + buttonUp.BackgroundImageLayout = ImageLayout.Zoom; + buttonUp.Location = new Point(842, 447); + buttonUp.Name = "buttonUp"; + buttonUp.Size = new Size(30, 30); + buttonUp.TabIndex = 4; + buttonUp.UseVisualStyleBackColor = true; + // + // FormAirBomber + // + AutoScaleDimensions = new SizeF(10F, 25F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(986, 540); + Controls.Add(buttonUp); + Controls.Add(buttonRight); + Controls.Add(buttonLeft); + Controls.Add(buttonDown); + Controls.Add(buttonCreate); + Name = "FormAirBomber"; + Text = "Form1"; + ResumeLayout(false); + } + + #endregion + + private Button buttonCreate; + private Button buttonDown; + private Button buttonLeft; + private Button buttonRight; + private Button buttonUp; + } +} \ No newline at end of file diff --git a/AirBomber/AirBomber/Form1.cs b/AirBomber/AirBomber/FormAirBomber.cs similarity index 53% rename from AirBomber/AirBomber/Form1.cs rename to AirBomber/AirBomber/FormAirBomber.cs index 0ca8021..e998b26 100644 --- a/AirBomber/AirBomber/Form1.cs +++ b/AirBomber/AirBomber/FormAirBomber.cs @@ -1,8 +1,8 @@ namespace AirBomber { - public partial class Form1 : Form + public partial class FormAirBomber : Form { - public Form1() + public FormAirBomber() { InitializeComponent(); } diff --git a/AirBomber/AirBomber/FormAirBomber.resx b/AirBomber/AirBomber/FormAirBomber.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/AirBomber/AirBomber/FormAirBomber.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/AirBomber/AirBomber/Program.cs b/AirBomber/AirBomber/Program.cs index 34d9512..76b85fe 100644 --- a/AirBomber/AirBomber/Program.cs +++ b/AirBomber/AirBomber/Program.cs @@ -11,7 +11,7 @@ namespace AirBomber // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(new FormAirBomber()); } } } \ No newline at end of file diff --git a/AirBomber/AirBomber/Properties/Resources.Designer.cs b/AirBomber/AirBomber/Properties/Resources.Designer.cs new file mode 100644 index 0000000..c458e7e --- /dev/null +++ b/AirBomber/AirBomber/Properties/Resources.Designer.cs @@ -0,0 +1,103 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace AirBomber.Properties { + using System; + + + /// + /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. + /// + // Этот класс создан автоматически классом StronglyTypedResourceBuilder + // с помощью такого средства, как ResGen или Visual Studio. + // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen + // с параметром /str или перестройте свой проект VS. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirBomber.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Перезаписывает свойство CurrentUICulture текущего потока для всех + /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowDown { + get { + object obj = ResourceManager.GetObject("arrowDown", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowLeft { + get { + object obj = ResourceManager.GetObject("arrowLeft", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowRight { + get { + object obj = ResourceManager.GetObject("arrowRight", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap arrowUp { + get { + object obj = ResourceManager.GetObject("arrowUp", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/AirBomber/AirBomber/Form1.resx b/AirBomber/AirBomber/Properties/Resources.resx similarity index 83% rename from AirBomber/AirBomber/Form1.resx rename to AirBomber/AirBomber/Properties/Resources.resx index 1af7de1..69274b7 100644 --- a/AirBomber/AirBomber/Form1.resx +++ b/AirBomber/AirBomber/Properties/Resources.resx @@ -117,4 +117,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ..\Resources\arrowDown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowUp.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowLeft.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\arrowRight.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + \ No newline at end of file diff --git a/AirBomber/AirBomber/Resources/arrowDown.png b/AirBomber/AirBomber/Resources/arrowDown.png new file mode 100644 index 0000000..f527adf Binary files /dev/null and b/AirBomber/AirBomber/Resources/arrowDown.png differ diff --git a/AirBomber/AirBomber/Resources/arrowLeft.png b/AirBomber/AirBomber/Resources/arrowLeft.png new file mode 100644 index 0000000..ad84ab3 Binary files /dev/null and b/AirBomber/AirBomber/Resources/arrowLeft.png differ diff --git a/AirBomber/AirBomber/Resources/arrowRight.png b/AirBomber/AirBomber/Resources/arrowRight.png new file mode 100644 index 0000000..08ca64d Binary files /dev/null and b/AirBomber/AirBomber/Resources/arrowRight.png differ diff --git a/AirBomber/AirBomber/Resources/arrowUp.png b/AirBomber/AirBomber/Resources/arrowUp.png new file mode 100644 index 0000000..20128d5 Binary files /dev/null and b/AirBomber/AirBomber/Resources/arrowUp.png differ