diff --git a/AntiAircraftGun.sln b/AntiAircraftGun.sln deleted file mode 100644 index b7808b4..0000000 --- a/AntiAircraftGun.sln +++ /dev/null @@ -1,25 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.7.33808.371 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AntiAircraftGun", "AntiAircraftGun\AntiAircraftGun.csproj", "{08E6BE2F-AC65-4661-8FB9-CC82073D7BA4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {08E6BE2F-AC65-4661-8FB9-CC82073D7BA4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08E6BE2F-AC65-4661-8FB9-CC82073D7BA4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08E6BE2F-AC65-4661-8FB9-CC82073D7BA4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08E6BE2F-AC65-4661-8FB9-CC82073D7BA4}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {71FC936E-B675-45C0-A3BA-F16DAF0C20ED} - EndGlobalSection -EndGlobal diff --git a/AntiAircraftGun/AntiAircraftGun.csproj b/AntiAircraftGun/AntiAircraftGun.csproj deleted file mode 100644 index 2b10ea1..0000000 --- a/AntiAircraftGun/AntiAircraftGun.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - WinExe - net6.0-windows - enable - true - enable - - - - - - - - - - - True - True - Resources.resx - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - - - - \ No newline at end of file diff --git a/AntiAircraftGun/Form1.Designer.cs b/AntiAircraftGun/Form1.Designer.cs deleted file mode 100644 index 4350061..0000000 --- a/AntiAircraftGun/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace AntiAircraftGun -{ - 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/AntiAircraftGun/Form1.cs b/AntiAircraftGun/Form1.cs deleted file mode 100644 index 90486ab..0000000 --- a/AntiAircraftGun/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace AntiAircraftGun -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} \ No newline at end of file diff --git a/AntiAircraftGun/Form1.resx b/AntiAircraftGun/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/AntiAircraftGun/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/AntiAircraftGun/FormAntiAircraftGun.cs b/AntiAircraftGun/FormAntiAircraftGun.cs deleted file mode 100644 index e2ab86a..0000000 --- a/AntiAircraftGun/FormAntiAircraftGun.cs +++ /dev/null @@ -1,78 +0,0 @@ -namespace ProjectAntiAircraftGun -{ - /// - /// " " - /// - public partial class FormAntiAircraftGun : Form - { - /// - /// - - /// - private DrawingAntiAircraftGun? _drawingAntiAircraftGun; - - /// - /// - /// - public FormAntiAircraftGun() - { - InitializeComponent(); - } - - - /// - /// - /// - private void Draw() - { - if (_drawingAntiAircraftGun == null) { return; } - Bitmap bmp = new(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); - Graphics gr = Graphics.FromImage(bmp); - _drawingAntiAircraftGun.DrawTransport(gr); - pictureBoxAntiAircraftGun.Image = bmp; - } - /// - /// "" - /// - /// - /// - private void ButtonCreateAntiAircraftGun(object sender, EventArgs e) - { - Random random = new(); - _drawingAntiAircraftGun = new DrawingAntiAircraftGun(); - _drawingAntiAircraftGun.Init(random.Next(100, 300), random.Next(1000, 3000), 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)), - pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); - _drawingAntiAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100)); - Draw(); - } - - /// - /// - /// - /// - /// - private void ButtonMove_Click(object sender, EventArgs e) - { - if (_drawingAntiAircraftGun == null) return; - - string name = ((Button)sender)?.Name ?? string.Empty; - switch (name) - { - case "buttonUp": - _drawingAntiAircraftGun.MoveTransport(DirectionType.Up); - break; - case "buttonDown": - _drawingAntiAircraftGun.MoveTransport(DirectionType.Down); - break; - case "buttonLeft": - _drawingAntiAircraftGun.MoveTransport(DirectionType.Left); - break; - case "buttonRight": - _drawingAntiAircraftGun.MoveTransport(DirectionType.Right); - break; - } - Draw(); - } - - } -} \ No newline at end of file diff --git a/AntiAircraftGun/Properties/Resources.Designer.cs b/AntiAircraftGun/Properties/Resources.Designer.cs deleted file mode 100644 index ce16850..0000000 --- a/AntiAircraftGun/Properties/Resources.Designer.cs +++ /dev/null @@ -1,103 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace AntiAircraftGun.Properties { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [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() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [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("AntiAircraftGun.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap bottom { - get { - object obj = ResourceManager.GetObject("bottom", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap left { - get { - object obj = ResourceManager.GetObject("left", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap right { - get { - object obj = ResourceManager.GetObject("right", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - - /// - /// Looks up a localized resource of type System.Drawing.Bitmap. - /// - internal static System.Drawing.Bitmap top { - get { - object obj = ResourceManager.GetObject("top", resourceCulture); - return ((System.Drawing.Bitmap)(obj)); - } - } - } -} diff --git a/AntiAircraftGun/Resources/bottom.jpg b/AntiAircraftGun/Resources/bottom.jpg deleted file mode 100644 index dc9c3c5..0000000 Binary files a/AntiAircraftGun/Resources/bottom.jpg and /dev/null differ diff --git a/AntiAircraftGun/Resources/left.jpg b/AntiAircraftGun/Resources/left.jpg deleted file mode 100644 index 9f81b45..0000000 Binary files a/AntiAircraftGun/Resources/left.jpg and /dev/null differ diff --git a/AntiAircraftGun/Resources/right.jpg b/AntiAircraftGun/Resources/right.jpg deleted file mode 100644 index e275b57..0000000 Binary files a/AntiAircraftGun/Resources/right.jpg and /dev/null differ diff --git a/AntiAircraftGun/Resources/top.jpg b/AntiAircraftGun/Resources/top.jpg deleted file mode 100644 index b6815d1..0000000 Binary files a/AntiAircraftGun/Resources/top.jpg and /dev/null differ diff --git a/AntiAircraftGun/DirectionType.cs b/ProjectAntiAirCraftGun/DirectionType.cs similarity index 100% rename from AntiAircraftGun/DirectionType.cs rename to ProjectAntiAirCraftGun/DirectionType.cs diff --git a/ProjectAntiAirCraftGun/DrawingObjects/DrawingAntiAircraftGun.cs b/ProjectAntiAirCraftGun/DrawingObjects/DrawingAntiAircraftGun.cs new file mode 100644 index 0000000..c24aac5 --- /dev/null +++ b/ProjectAntiAirCraftGun/DrawingObjects/DrawingAntiAircraftGun.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectAntiAircraftGun.Entities; + +namespace ProjectAntiAircraftGun.DrawingObjects +{ + /// + /// Класс, отвечающий за прорисовку и перемещение объекта-сущности + /// + public class DrawingAntiAircraftGun : DrawingTank + { + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Дополнительный цвет + /// Признак наличия радара + /// Признак наличия люка + /// Признак наличия пушки + /// Ширина картинки + /// Высота картинки + public DrawingAntiAircraftGun(int speed, double weight, Color bodyColor, Color +additionalColor, bool radar, bool hatch, bool cannon, int width, int height) : + base(speed, weight, bodyColor, additionalColor, width, height, 102, 139) + { + if (EntityTank != null) + { + EntityTank = new EntityAntiAircraftGun(speed, weight, bodyColor, + additionalColor, radar, hatch, cannon); + } + } + + public override void DrawTransport(Graphics g) + { + + if (EntityTank is not EntityAntiAircraftGun antiAircraftGun) + { + return; + } + + Pen pen = new(Color.Black); + pen.Width = 2; + + base.DrawTransport(g); + + // радар + if (antiAircraftGun.Radar) + { + Pen penRadar = new(Color.DarkGreen); + g.DrawEllipse(penRadar, _startPosX + 52, _startPosY + 46, 21, 12); + g.DrawEllipse(penRadar, _startPosX + 55, _startPosY + 48, 14, 8); + pen = new(Color.Green); + g.DrawLine(penRadar, _startPosX + 61, _startPosY + 52, _startPosX + 70, _startPosY + 48); + } + + // пушка + if (antiAircraftGun.Cannon) + { + g.DrawLine(pen, _startPosX + 54, _startPosY + 33, _startPosX + 113, _startPosY + 2); + g.DrawLine(pen, _startPosX + 57, _startPosY + 35, _startPosX + 122, _startPosY + 2); + } + + // люк + if (antiAircraftGun.Hatch) + { + pen = new(antiAircraftGun.AdditionalColor); + g.DrawRectangle(pen, _startPosX + 88, _startPosY + 64, 17, 6); + g.DrawLine(pen, _startPosX + 88, _startPosY + 67, _startPosX + 105, _startPosY + 67); + g.DrawLine(pen, _startPosX + 94, _startPosY + 64, _startPosX + 94, _startPosY + 70); + } + } + } +} diff --git a/AntiAircraftGun/DrawingAntiAircraftGun.cs b/ProjectAntiAirCraftGun/DrawingObjects/DrawingTank.cs similarity index 51% rename from AntiAircraftGun/DrawingAntiAircraftGun.cs rename to ProjectAntiAirCraftGun/DrawingObjects/DrawingTank.cs index 6a9527d..c052327 100644 --- a/AntiAircraftGun/DrawingAntiAircraftGun.cs +++ b/ProjectAntiAirCraftGun/DrawingObjects/DrawingTank.cs @@ -3,147 +3,213 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using ProjectAntiAircraftGun.Entities; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; -namespace ProjectAntiAircraftGun +namespace ProjectAntiAircraftGun.DrawingObjects { - /// - /// Класс, отвечающий за прорисовку и перемещение объекта-сущности - /// - internal class DrawingAntiAircraftGun + public class DrawingTank { /// /// Класс-сущность /// - public EntityAntiAircraftGun? EntityAntiAircraftGun { get; private set; } - + public EntityTank? EntityTank { get; protected set; } /// /// Ширина окна /// - private static int _pictureWidth; - + private int _pictureWidth; /// /// Высота окна /// - private static int _pictureHeight; - + private int _pictureHeight; /// - /// Левая координата прорисовки зенитной установки + /// Левая координата прорисовки танка /// - private int _startPosX; - + protected int _startPosX; /// - /// Верхняя координата прорисовки зенитной установки + /// Верхняя кооридната прорисовки танка /// - private int _startPosY; - + protected int _startPosY; /// - /// Ширина прорисовки зенитной установки + /// Ширина прорисовки танка /// - private readonly int _AntiAircraftGunWidth = 125; - + protected readonly int _tankWidth = 130; /// - /// Высота прорисовки зенитной установки + /// Высота прорисовки танка /// - private readonly int _AntiAircraftGunHeight = 100; + protected readonly int _tankHeight = 102; /// - /// Инициализация свойств + /// Координата X объекта + /// + public int GetPosX => _startPosX; + /// + /// Координата Y объекта + /// + public int GetPosY => _startPosY; + /// + /// Ширина объекта + /// + public int GetWidth => _tankWidth; + /// + /// Высота объекта + /// + public int GetHeight => _tankHeight; + /// + /// Конструктор /// /// Скорость - /// Вес зенитной установки + /// Вес /// Основной цвет /// Дополнительный цвет - /// Признак наличия радара - /// Признак наличия люка зенитной установки - /// Признак наличия пушки зенитной установки /// Ширина картинки /// Высота картинки - /// true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах - public bool Init(int speed, int weight, Color bodyColor, Color additionalColor, bool radar, bool hatch, bool cannon, int width, int height) + public DrawingTank(int speed, double weight, Color bodyColor, Color additionalColor, int + width, int height) + { + + _pictureWidth = width; + _pictureHeight = height; + EntityTank = new EntityTank(speed, weight, bodyColor, additionalColor); + + if (_pictureWidth > _tankWidth && _pictureHeight > _tankHeight) + { + EntityTank = new EntityTank(speed, weight, bodyColor, additionalColor); + } + else + { + EntityTank = null; + } + } + /// + /// Конструктор + /// + /// Скорость + /// Вес + /// Основной цвет + /// Ширина картинки + /// Высота картинки + /// Ширина прорисовки танка + /// Высота прорисовки танка + protected DrawingTank(int speed, double weight, Color bodyColor, Color additionalColor, int + width, int height, int tankWidth, int tankHeight) { _pictureWidth = width; _pictureHeight = height; - if (_pictureWidth > _AntiAircraftGunWidth && _pictureHeight > _AntiAircraftGunHeight) { - EntityAntiAircraftGun = new EntityAntiAircraftGun(); - EntityAntiAircraftGun.Init(speed, weight, bodyColor, additionalColor, radar, hatch, cannon); - return true; - } - return false; + EntityTank = new EntityTank(speed, weight, bodyColor, additionalColor); + + if (_pictureWidth > _tankWidth && _pictureHeight > _tankHeight) + { + EntityTank = new EntityTank(speed, weight, bodyColor, additionalColor); + } + else + { + EntityTank = null; + } } + /// + /// Проверка, что объект может переместится по указанному направлению + /// + /// Направление + /// true - можно переместится по указанному направлению + public bool CanMove(DirectionType direction) + { + if (EntityTank == null) + { + return false; + } + return direction switch + { + //влево + DirectionType.Left => _startPosX - EntityTank.Step > 0, + //вверх + DirectionType.Up => _startPosY - EntityTank.Step > 0, + // вправо + DirectionType.Right => _startPosX + _tankWidth + EntityTank.Step < _pictureWidth, + //вниз + DirectionType.Down => _startPosY + _tankHeight + EntityTank.Step < _pictureHeight, + _ => false, + }; + } + + /// + /// Изменение направления перемещения + /// + /// Направление + public void MoveTransport(DirectionType direction) + { + if (!CanMove(direction) || EntityTank == null) + { + return; + } + switch (direction) + { + //влево + case DirectionType.Left: + _startPosX -= (int)EntityTank.Step; + break; + //вверх + case DirectionType.Up: + _startPosY -= (int)EntityTank.Step; + break; + // вправо + case DirectionType.Right: + _startPosX += (int)EntityTank.Step; + break; + //вниз + case DirectionType.Down: + _startPosY += (int)EntityTank.Step; + break; + } + } /// /// Установка позиции /// - /// Координата Х + /// Координата X /// Координата Y public void SetPosition(int x, int y) { - if (EntityAntiAircraftGun == null) return; - while (x + _AntiAircraftGunWidth > _pictureWidth) + if (EntityTank == null) return; + while (x + _tankWidth > _pictureWidth) { - x -= (int)EntityAntiAircraftGun.Step; + x -= (int)EntityTank.Step; } while (x < 0) { - x += (int)EntityAntiAircraftGun.Step; + x += (int)EntityTank.Step; } - while (y + _AntiAircraftGunHeight > _pictureHeight) + while (y + _tankHeight > _pictureHeight) { - y -= (int)EntityAntiAircraftGun.Step; + y -= (int)EntityTank.Step; } while (y < 0) { - y += (int)EntityAntiAircraftGun.Step; + y += (int)EntityTank.Step; } _startPosX = x; _startPosY = y; } - public void MoveTransport(DirectionType direction) + /// + /// Прорисовка объекта + /// + /// + public virtual void DrawTransport(Graphics g) { - if (EntityAntiAircraftGun == null) - { return; } - switch (direction) - { - case DirectionType.Left: - if (_startPosX - EntityAntiAircraftGun.Step > 0) - { - _startPosX -= (int)EntityAntiAircraftGun.Step; - } - break; - case DirectionType.Right: - if (_startPosX + _AntiAircraftGunWidth + EntityAntiAircraftGun.Step < DrawingAntiAircraftGun._pictureWidth) - { - _startPosX += (int)EntityAntiAircraftGun.Step; - } - break; - case DirectionType.Up: - if (_startPosY - EntityAntiAircraftGun.Step > 0) - { - _startPosY -= (int)EntityAntiAircraftGun.Step; - } - break; - case DirectionType.Down: - if (_startPosY + _AntiAircraftGunHeight + EntityAntiAircraftGun.Step < DrawingAntiAircraftGun._pictureHeight) - { - _startPosY += (int)EntityAntiAircraftGun.Step; - } - break; - } - } - public void DrawTransport(Graphics g) - { - if (EntityAntiAircraftGun == null) { return; } + if (EntityTank == null) { return; } Pen pen = new(Color.Black); pen.Width = 2; - Brush brush = new SolidBrush(EntityAntiAircraftGun.BodyColor); - Brush additionalBrush = new SolidBrush(EntityAntiAircraftGun.AdditionalColor); + Brush brush = new SolidBrush(EntityTank.BodyColor); + + Random random = new Random(); + Brush additionalBrush = new SolidBrush(EntityTank.AdditionalColor); // границы зенитной установки g.DrawRectangle(pen, _startPosX + 3, _startPosY + 60, 121, 23); g.DrawRectangle(pen, _startPosX + 20, _startPosY + 43, 54, 16); g.DrawRectangle(pen, _startPosX + 42, _startPosY + 33, 16, 9); - + // корпус g.FillRectangle(brush, _startPosX + 3, _startPosY + 60, 121, 23); g.FillRectangle(brush, _startPosX + 20, _startPosY + 43, 54, 16); @@ -194,32 +260,6 @@ namespace ProjectAntiAircraftGun g.FillEllipse(brush, _startPosX + 43, _startPosY + 83, 7, 5); g.FillEllipse(brush, _startPosX + 64, _startPosY + 83, 7, 5); g.FillEllipse(brush, _startPosX + 82, _startPosY + 83, 7, 5); - - // радар - if (EntityAntiAircraftGun.Radar) - { - Pen penRadar = new(Color.DarkGreen); - g.DrawEllipse(penRadar, _startPosX + 52, _startPosY + 46, 21, 12); - g.DrawEllipse(penRadar, _startPosX + 55, _startPosY + 48, 14, 8); - pen = new(Color.Green); - g.DrawLine(penRadar, _startPosX + 61, _startPosY + 52, _startPosX + 70, _startPosY + 48); - } - - // пушка - if (EntityAntiAircraftGun.Cannon) - { - g.DrawLine(pen, _startPosX + 54, _startPosY + 33, _startPosX + 113, _startPosY + 2); - g.DrawLine(pen, _startPosX + 57, _startPosY + 35, _startPosX + 122, _startPosY + 2); - } - - // люк - if (EntityAntiAircraftGun.Hatch) - { - pen = new(EntityAntiAircraftGun.AdditionalColor); - g.DrawRectangle(pen, _startPosX + 88, _startPosY + 64, 17, 6); - g.DrawLine(pen, _startPosX + 88, _startPosY + 67, _startPosX + 105, _startPosY + 67); - g.DrawLine(pen, _startPosX + 94, _startPosY + 64, _startPosX + 94, _startPosY + 70); - } } } } diff --git a/AntiAircraftGun/EntityAntiAircraftGun.cs b/ProjectAntiAirCraftGun/Entities/EntityAntiAircraftGun.cs similarity index 73% rename from AntiAircraftGun/EntityAntiAircraftGun.cs rename to ProjectAntiAirCraftGun/Entities/EntityAntiAircraftGun.cs index da95d5e..d9d0ee6 100644 --- a/AntiAircraftGun/EntityAntiAircraftGun.cs +++ b/ProjectAntiAirCraftGun/Entities/EntityAntiAircraftGun.cs @@ -4,24 +4,10 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ProjectAntiAircraftGun +namespace ProjectAntiAircraftGun.Entities { - public class EntityAntiAircraftGun + public class EntityAntiAircraftGun : EntityTank { - /// - /// Скорость - /// - public int Speed { get; private set; } - - /// - /// Вес - /// - public int Weight { get; private set; } - - /// - /// Основной цвет - /// - public Color BodyColor { get; private set; } /// /// Дополнительный цвет (для опциональных элементов) @@ -42,7 +28,7 @@ namespace ProjectAntiAircraftGun /// пушка танк /// public bool Cannon { get; private set; } - + /// /// Шаг перемещения зенитной установки /// @@ -58,11 +44,8 @@ namespace ProjectAntiAircraftGun /// Признак наличия радара /// Признак наличия люка зенитной установки /// Признак наличия пушки зенитной установки - public void Init(int speed, int weight, Color bodyColor, Color additionalColor, bool radar, bool hatch, bool cannon) + public EntityAntiAircraftGun(int speed, double weight, Color bodyColor, Color additionalColor, bool radar, bool hatch, bool cannon) : base(speed, weight, bodyColor, additionalColor) { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; AdditionalColor = additionalColor; Hatch = hatch; Radar = radar; diff --git a/ProjectAntiAirCraftGun/Entities/EntityTank.cs b/ProjectAntiAirCraftGun/Entities/EntityTank.cs new file mode 100644 index 0000000..dbe6140 --- /dev/null +++ b/ProjectAntiAirCraftGun/Entities/EntityTank.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAntiAircraftGun.Entities +{ + public class EntityTank + { + /// + /// Скорость + /// + public int Speed { get; private set; } + /// + /// Вес + /// + public double Weight { get; private set; } + /// + /// Основной цвет + /// + public Color BodyColor { get; private set; } + /// + /// Дополнительный цвет + /// + public Color AdditionalColor { get; private set; } + /// + /// Шаг перемещения автомобиля + /// + public double Step => (double)Speed * 100 / Weight; + /// + /// Конструктор с параметрами + /// + /// Скорость + /// Вес автомобиля + /// Основной цвет + public EntityTank(int speed, double weight, Color bodyColor, Color additionalColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + AdditionalColor = additionalColor; + } + } +} diff --git a/AntiAircraftGun/FormAntiAircraftGun.Designer.cs b/ProjectAntiAirCraftGun/FormAntiAircraftGun.Designer.cs similarity index 59% rename from AntiAircraftGun/FormAntiAircraftGun.Designer.cs rename to ProjectAntiAirCraftGun/FormAntiAircraftGun.Designer.cs index 37e3ac7..eb2e726 100644 --- a/AntiAircraftGun/FormAntiAircraftGun.Designer.cs +++ b/ProjectAntiAirCraftGun/FormAntiAircraftGun.Designer.cs @@ -29,11 +29,14 @@ private void InitializeComponent() { pictureBoxAntiAircraftGun = new PictureBox(); - createButton = new Button(); + buttonCreateAntiAircraftGun = new Button(); buttonRight = new Button(); buttonLeft = new Button(); buttonDown = new Button(); buttonUp = new Button(); + comboBoxStrategy = new ComboBox(); + buttonCreateTank = new Button(); + buttonStep = new Button(); ((System.ComponentModel.ISupportInitialize)pictureBoxAntiAircraftGun).BeginInit(); SuspendLayout(); // @@ -47,21 +50,21 @@ pictureBoxAntiAircraftGun.TabIndex = 0; pictureBoxAntiAircraftGun.TabStop = false; // - // createButton + // buttonCreateAntiAircraftGun // - createButton.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - createButton.Location = new Point(12, 415); - createButton.Name = "createButton"; - createButton.Size = new Size(75, 23); - createButton.TabIndex = 1; - createButton.Text = "создать"; - createButton.UseVisualStyleBackColor = true; - createButton.Click += ButtonCreateAntiAircraftGun; + buttonCreateAntiAircraftGun.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateAntiAircraftGun.Location = new Point(12, 415); + buttonCreateAntiAircraftGun.Name = "buttonCreateAntiAircraftGun"; + buttonCreateAntiAircraftGun.Size = new Size(174, 23); + buttonCreateAntiAircraftGun.TabIndex = 1; + buttonCreateAntiAircraftGun.Text = "создать зенитную установку"; + buttonCreateAntiAircraftGun.UseVisualStyleBackColor = true; + buttonCreateAntiAircraftGun.Click += ButtonCreateAntiAircraftGun; // // buttonRight // buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonRight.BackgroundImage = AntiAircraftGun.Properties.Resources.right; + buttonRight.BackgroundImage = Properties.Resources.png_transparent_grammatical_person_paper_narration_direzione_didattica_statale_gestione_scuola_elementare_copy_print_right_arrow_miscellaneous_game_angle; buttonRight.BackgroundImageLayout = ImageLayout.Zoom; buttonRight.Location = new Point(739, 413); buttonRight.Name = "buttonRight"; @@ -73,7 +76,7 @@ // buttonLeft // buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonLeft.BackgroundImage = AntiAircraftGun.Properties.Resources.left; + buttonLeft.BackgroundImage = Properties.Resources.left; buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; buttonLeft.Location = new Point(605, 413); buttonLeft.Name = "buttonLeft"; @@ -85,7 +88,7 @@ // buttonDown // buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonDown.BackgroundImage = AntiAircraftGun.Properties.Resources.bottom; + buttonDown.BackgroundImage = Properties.Resources.bottom; buttonDown.BackgroundImageLayout = ImageLayout.Zoom; buttonDown.Location = new Point(672, 415); buttonDown.Name = "buttonDown"; @@ -97,7 +100,7 @@ // buttonUp // buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonUp.BackgroundImage = AntiAircraftGun.Properties.Resources.top; + buttonUp.BackgroundImage = Properties.Resources.top; buttonUp.BackgroundImageLayout = ImageLayout.Zoom; buttonUp.Location = new Point(672, 379); buttonUp.Name = "buttonUp"; @@ -106,16 +109,52 @@ buttonUp.UseVisualStyleBackColor = true; buttonUp.Click += ButtonMove_Click; // + // comboBoxStrategy + // + comboBoxStrategy.Anchor = AnchorStyles.Top | AnchorStyles.Right; + comboBoxStrategy.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled = true; + comboBoxStrategy.Items.AddRange(new object[] { "0", "1" }); + comboBoxStrategy.Location = new Point(679, 0); + comboBoxStrategy.Name = "comboBoxStrategy"; + comboBoxStrategy.Size = new Size(121, 23); + comboBoxStrategy.TabIndex = 9; + // + // buttonCreateTank + // + buttonCreateTank.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; + buttonCreateTank.Location = new Point(192, 415); + buttonCreateTank.Name = "buttonCreateTank"; + buttonCreateTank.Size = new Size(108, 23); + buttonCreateTank.TabIndex = 10; + buttonCreateTank.Text = "создать танк"; + buttonCreateTank.UseVisualStyleBackColor = true; + buttonCreateTank.Click += ButtonCreateTank_Click; + // + // buttonStep + // + buttonStep.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonStep.Location = new Point(704, 29); + buttonStep.Name = "buttonStep"; + buttonStep.Size = new Size(75, 23); + buttonStep.TabIndex = 11; + buttonStep.Text = "шаг"; + buttonStep.UseVisualStyleBackColor = true; + buttonStep.Click += ButtonStep_Click; + // // FormAntiAircraftGun // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(800, 450); + Controls.Add(buttonStep); + Controls.Add(buttonCreateTank); + Controls.Add(comboBoxStrategy); Controls.Add(buttonUp); Controls.Add(buttonDown); Controls.Add(buttonLeft); Controls.Add(buttonRight); - Controls.Add(createButton); + Controls.Add(buttonCreateAntiAircraftGun); Controls.Add(pictureBoxAntiAircraftGun); Name = "FormAntiAircraftGun"; Text = "Зенитная установка"; @@ -127,10 +166,13 @@ #endregion private PictureBox pictureBoxAntiAircraftGun; - private Button createButton; + private Button buttonCreateAntiAircraftGun; private Button buttonRight; private Button buttonLeft; private Button buttonDown; private Button buttonUp; + private Button buttonCreateTank; + private Button buttonStep; + private ComboBox comboBoxStrategy; } } \ No newline at end of file diff --git a/ProjectAntiAirCraftGun/FormAntiAircraftGun.cs b/ProjectAntiAirCraftGun/FormAntiAircraftGun.cs new file mode 100644 index 0000000..a9d1f24 --- /dev/null +++ b/ProjectAntiAirCraftGun/FormAntiAircraftGun.cs @@ -0,0 +1,156 @@ +using ProjectAntiAircraftGun.DrawingObjects; +using ProjectAntiAircraftGun.MovementStrategy; + +namespace ProjectAntiAircraftGun +{ + /// + /// " " + /// + public partial class FormAntiAircraftGun : Form + { + /// + /// - + /// + private DrawingTank? _drawingTank; + /// + /// + /// + private AbstractStrategy? _abstractStrategy; + + /// + /// + /// + public FormAntiAircraftGun() + { + InitializeComponent(); + } + + /// + /// + /// + private void Draw() + { + if (_drawingTank == null) + { + return; + } + Bitmap bmp = new(pictureBoxAntiAircraftGun.Width, + pictureBoxAntiAircraftGun.Height); + Graphics gr = Graphics.FromImage(bmp); + _drawingTank.DrawTransport(gr); + pictureBoxAntiAircraftGun.Image = bmp; + } + + /// + /// " " + /// + /// + /// + private void ButtonCreateTank_Click(object sender, EventArgs e) + { + Random random = new(); + _drawingTank = new DrawingTank(random.Next(100, 300), + random.Next(1000, 3000), + 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)), + pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); + _drawingTank.SetPosition(random.Next(10, 100), random.Next(10, + 100)); + Draw(); + } + + /// + /// " " + /// + /// + /// + private void ButtonCreateAntiAircraftGun(object sender, EventArgs e) + { + Random random = new(); + _drawingTank = new DrawingAntiAircraftGun(random.Next(100, 300), + random.Next(1000, 3000), + 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)), + pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height); + _drawingTank.SetPosition(random.Next(10, 100), random.Next(10, + 100)); + Draw(); + + } + + /// + /// + /// + /// + /// + private void ButtonMove_Click(object sender, EventArgs e) + { + if (_drawingTank == null) return; + + string name = ((Button)sender)?.Name ?? string.Empty; + switch (name) + { + case "buttonUp": + _drawingTank.MoveTransport(DirectionType.Up); + break; + case "buttonDown": + _drawingTank.MoveTransport(DirectionType.Down); + break; + case "buttonLeft": + _drawingTank.MoveTransport(DirectionType.Left); + break; + case "buttonRight": + _drawingTank.MoveTransport(DirectionType.Right); + break; + } + Draw(); + } + + /// + /// "" + /// + /// + /// + private void ButtonStep_Click(object sender, EventArgs e) + { + if (_drawingTank == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _abstractStrategy = comboBoxStrategy.SelectedIndex + switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.SetData(new + DrawingObjectTank(_drawingTank), pictureBoxAntiAircraftGun.Width, + pictureBoxAntiAircraftGun.Height); + comboBoxStrategy.Enabled = false; + } + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.MakeStep(); + Draw(); + if (_abstractStrategy.GetStatus() == Status.Finish) + { + comboBoxStrategy.Enabled = true; + _abstractStrategy = null; + } + } + } +} \ No newline at end of file diff --git a/AntiAircraftGun/FormAntiAircraftGun.resx b/ProjectAntiAirCraftGun/FormAntiAircraftGun.resx similarity index 100% rename from AntiAircraftGun/FormAntiAircraftGun.resx rename to ProjectAntiAirCraftGun/FormAntiAircraftGun.resx diff --git a/ProjectAntiAirCraftGun/MovementStrategy/AbstractStrategy.cs b/ProjectAntiAirCraftGun/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..4fe3140 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,132 @@ +using ProjectAntiAircraftGun; +using static System.Windows.Forms.AxHost; +using static System.Windows.Forms.VisualStyles.VisualStyleElement; + +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Класс-стратегия перемещения объекта + /// + public abstract class AbstractStrategy + { + /// + /// Перемещаемый объект + /// + private IMoveableObject? _moveableObject; + /// + /// Статус перемещения + /// + private Status _state = Status.NotInit; + /// + /// Ширина поля + /// + protected int FieldWidth { get; private set; } + /// + /// Высота поля + /// + protected int FieldHeight { get; private set; } + /// + /// Статус перемещения + /// + public Status GetStatus() { return _state; } + /// + /// Установка данных + /// + /// Перемещаемый объект + /// Ширина поля + /// Высота поля + public void SetData(IMoveableObject moveableObject, int width, int + height) + { + if (moveableObject == null) + { + _state = Status.NotInit; + return; + } + _state = Status.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + /// + /// Шаг перемещения + /// + public void MakeStep() + { + if (_state != Status.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = Status.Finish; + return; + } + MoveToTarget(); + } + + /// + /// Перемещение влево + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveLeft() => MoveTo(DirectionType.Left); + /// + /// Перемещение вправо + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveRight() => MoveTo(DirectionType.Right); + /// + /// Перемещение вверх + /// + /// Результат перемещения (true - удалось переместиться,false - неудача) + protected bool MoveUp() => MoveTo(DirectionType.Up); + /// + /// Перемещение вниз + /// + /// Результат перемещения (true - удалось переместиться, false - неудача) + protected bool MoveDown() => MoveTo(DirectionType.Down); + /// + /// Параметры объекта + /// + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + /// + /// Шаг объекта + /// + /// + protected int? GetStep() + { + if (_state != Status.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + /// + /// Перемещение к цели + /// + protected abstract void MoveToTarget(); + /// + /// Достигнута ли цель + /// + /// + protected abstract bool IsTargetDestinaion(); + /// + /// Попытка перемещения в требуемом направлении + /// + /// Направление + /// Результат попытки (true - удалось переместиться, false - неудача) + private bool MoveTo(DirectionType directionType) + { + if (_state != Status.InProgress) + { + return false; + } + if (_moveableObject?.CheckCanMove(directionType) ?? false) + { + _moveableObject.MoveObject(directionType); + return true; + } + return false; + } + } +} \ No newline at end of file diff --git a/ProjectAntiAirCraftGun/MovementStrategy/DrawingObjectTank.cs b/ProjectAntiAirCraftGun/MovementStrategy/DrawingObjectTank.cs new file mode 100644 index 0000000..1229ff9 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/DrawingObjectTank.cs @@ -0,0 +1,32 @@ +using ProjectAntiAircraftGun.DrawingObjects; +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Реализация интерфейса IDrawningObject для работы с объектом Drawning (паттерн Adapter) + + public class DrawingObjectTank : IMoveableObject + { + private readonly DrawingTank? _drawingTank = null; + public DrawingObjectTank(DrawingTank drawingTank) + { + _drawingTank = drawingTank; + } + public ObjectParameters? GetObjectPosition + { + get + { + if (_drawingTank == null || _drawingTank.EntityTank == null) + { + return null; + } + return new ObjectParameters(_drawingTank.GetPosX, + _drawingTank.GetPosY, _drawingTank.GetWidth, _drawingTank.GetHeight); + } + } + public int GetStep => (int)(_drawingTank?.EntityTank?.Step ?? 0); + public bool CheckCanMove(DirectionType direction) => + _drawingTank?.CanMove(direction) ?? false; + public void MoveObject(DirectionType direction) => + _drawingTank?.MoveTransport(direction); + } +} diff --git a/ProjectAntiAirCraftGun/MovementStrategy/IMoveableObject.cs b/ProjectAntiAirCraftGun/MovementStrategy/IMoveableObject.cs new file mode 100644 index 0000000..e29e723 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/IMoveableObject.cs @@ -0,0 +1,29 @@ +using ProjectAntiAircraftGun; +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Интерфейс для работы с перемещаемым объектом + /// + public interface IMoveableObject + { + /// + /// Получение координаты X объекта + /// + ObjectParameters? GetObjectPosition { get; } + /// + /// Шаг объекта + /// + int GetStep { get; } + /// + /// Проверка, можно ли переместиться по нужному направлению + /// + /// + /// + bool CheckCanMove(DirectionType direction); + /// + /// Изменение направления пермещения объекта + /// + /// Направление + void MoveObject(DirectionType direction); + } +} \ No newline at end of file diff --git a/ProjectAntiAirCraftGun/MovementStrategy/MoveToBorder.cs b/ProjectAntiAirCraftGun/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..b9b4c06 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,60 @@ +using ProjectAntiAircraftGun.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Стратегия перемещения объекта к правому нижнему краю формы + /// + public class MoveToBorder : AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal <= FieldWidth && + objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth && + objParams.ObjectMiddleVertical <= FieldHeight && + objParams.ObjectMiddleVertical + GetStep() >= FieldHeight; + } + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.ObjectMiddleHorizontal - FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + var diffY = objParams.ObjectMiddleVertical - FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} diff --git a/ProjectAntiAirCraftGun/MovementStrategy/MoveToCenter.cs b/ProjectAntiAirCraftGun/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..972fbf9 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Стратегия перемещения объекта в центр экрана + /// + public class MoveToCenter : AbstractStrategy + { + protected override bool IsTargetDestinaion() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && + objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical <= FieldHeight / 2 && + objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} + diff --git a/ProjectAntiAirCraftGun/MovementStrategy/ObjectParametrs.cs b/ProjectAntiAirCraftGun/MovementStrategy/ObjectParametrs.cs new file mode 100644 index 0000000..2348c75 --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/ObjectParametrs.cs @@ -0,0 +1,51 @@ +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Параметры-координаты объекта + /// + public class ObjectParameters + { + private readonly int _x; + private readonly int _y; + private readonly int _width; + private readonly int _height; + /// + /// Левая граница + /// + public int LeftBorder => _x; + /// + /// Верхняя граница + /// + public int TopBorder => _y; + /// + /// Правая граница + /// + public int RightBorder => _x + _width; + /// + /// Нижняя граница + /// + public int DownBorder => _y + _height; + /// + /// Середина объекта + /// + public int ObjectMiddleHorizontal => _x + _width / 2; + /// + /// Середина объекта + /// + public int ObjectMiddleVertical => _y + _height / 2; + /// + /// Конструктор + /// + /// Координата X + /// Координата Y + /// Ширина + /// Высота + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } + } +} diff --git a/ProjectAntiAirCraftGun/MovementStrategy/Status.cs b/ProjectAntiAirCraftGun/MovementStrategy/Status.cs new file mode 100644 index 0000000..ee3877c --- /dev/null +++ b/ProjectAntiAirCraftGun/MovementStrategy/Status.cs @@ -0,0 +1,12 @@ +namespace ProjectAntiAircraftGun.MovementStrategy +{ + /// + /// Статус выполнения операции перемещения + /// + public enum Status + { + NotInit, + InProgress, + Finish + } +} diff --git a/AntiAircraftGun/Program.cs b/ProjectAntiAirCraftGun/Program.cs similarity index 100% rename from AntiAircraftGun/Program.cs rename to ProjectAntiAirCraftGun/Program.cs diff --git a/AntiAircraftGun/ProjectAntiAircraftGun.csproj b/ProjectAntiAirCraftGun/ProjectAntiAircraftGun.csproj similarity index 100% rename from AntiAircraftGun/ProjectAntiAircraftGun.csproj rename to ProjectAntiAirCraftGun/ProjectAntiAircraftGun.csproj diff --git a/AntiAircraftGun/ProjectAntiAircraftGun.sln b/ProjectAntiAirCraftGun/ProjectAntiAircraftGun.sln similarity index 100% rename from AntiAircraftGun/ProjectAntiAircraftGun.sln rename to ProjectAntiAirCraftGun/ProjectAntiAircraftGun.sln diff --git a/ProjectAntiAirCraftGun/Properties/Resources.Designer.cs b/ProjectAntiAirCraftGun/Properties/Resources.Designer.cs new file mode 100644 index 0000000..758a8e2 --- /dev/null +++ b/ProjectAntiAirCraftGun/Properties/Resources.Designer.cs @@ -0,0 +1,145 @@ +//------------------------------------------------------------------------------ +// +// Этот код создан программой. +// Исполняемая версия:4.0.30319.42000 +// +// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае +// повторной генерации кода. +// +//------------------------------------------------------------------------------ + +namespace ProjectAntiAircraftGun.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("ProjectAntiAircraftGun.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 bottom { + get { + object obj = ResourceManager.GetObject("bottom", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left { + get { + object obj = ResourceManager.GetObject("left", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_clipart_computer_icons_uma_musume_pretty_derby_fate_grand_order_saber_kemono_friends_three_arrow_game_angle { + get { + object obj = ResourceManager.GetObject("png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-" + + "friends-three-arrow-game-angle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_transparent_arrow_arrow_cdr_angle_triangle { + get { + object obj = ResourceManager.GetObject("png-transparent-arrow-arrow-cdr-angle-triangle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_transparent_arrow_left_thin_zondicons_icon { + get { + object obj = ResourceManager.GetObject("png-transparent-arrow-left-thin-zondicons-icon", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap png_transparent_grammatical_person_paper_narration_direzione_didattica_statale_gestione_scuola_elementare_copy_print_right_arrow_miscellaneous_game_angle { + get { + object obj = ResourceManager.GetObject("png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-ge" + + "stione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right { + get { + object obj = ResourceManager.GetObject("right", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Поиск локализованного ресурса типа System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap top { + get { + object obj = ResourceManager.GetObject("top", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/AntiAircraftGun/Properties/Resources.resx b/ProjectAntiAirCraftGun/Properties/Resources.resx similarity index 77% rename from AntiAircraftGun/Properties/Resources.resx rename to ProjectAntiAirCraftGun/Properties/Resources.resx index dde4c2d..4f804e0 100644 --- a/AntiAircraftGun/Properties/Resources.resx +++ b/ProjectAntiAirCraftGun/Properties/Resources.resx @@ -118,16 +118,28 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - ..\Resources\left.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\png-transparent-arrow-arrow-cdr-angle-triangle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\right.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\top.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\png-transparent-arrow-left-thin-zondicons-icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\bottom.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\bottom.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\left.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\right.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\top.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/AntiAircraftGun/Resources/bottom.png b/ProjectAntiAirCraftGun/Resources/bottom.png similarity index 100% rename from AntiAircraftGun/Resources/bottom.png rename to ProjectAntiAirCraftGun/Resources/bottom.png diff --git a/AntiAircraftGun/Resources/left.png b/ProjectAntiAirCraftGun/Resources/left.png similarity index 100% rename from AntiAircraftGun/Resources/left.png rename to ProjectAntiAirCraftGun/Resources/left.png diff --git a/AntiAircraftGun/Resources/png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png b/ProjectAntiAirCraftGun/Resources/png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png similarity index 100% rename from AntiAircraftGun/Resources/png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png rename to ProjectAntiAirCraftGun/Resources/png-clipart-computer-icons-uma-musume-pretty-derby-fate-grand-order-saber-kemono-friends-three-arrow-game-angle.png diff --git a/AntiAircraftGun/Resources/png-transparent-arrow-arrow-cdr-angle-triangle.png b/ProjectAntiAirCraftGun/Resources/png-transparent-arrow-arrow-cdr-angle-triangle.png similarity index 100% rename from AntiAircraftGun/Resources/png-transparent-arrow-arrow-cdr-angle-triangle.png rename to ProjectAntiAirCraftGun/Resources/png-transparent-arrow-arrow-cdr-angle-triangle.png diff --git a/AntiAircraftGun/Resources/png-transparent-arrow-left-thin-zondicons-icon.png b/ProjectAntiAirCraftGun/Resources/png-transparent-arrow-left-thin-zondicons-icon.png similarity index 100% rename from AntiAircraftGun/Resources/png-transparent-arrow-left-thin-zondicons-icon.png rename to ProjectAntiAirCraftGun/Resources/png-transparent-arrow-left-thin-zondicons-icon.png diff --git a/AntiAircraftGun/Resources/png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png b/ProjectAntiAirCraftGun/Resources/png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png similarity index 100% rename from AntiAircraftGun/Resources/png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png rename to ProjectAntiAirCraftGun/Resources/png-transparent-grammatical-person-paper-narration-direzione-didattica-statale-gestione-scuola-elementare-copy-print-right-arrow-miscellaneous-game-angle.png diff --git a/AntiAircraftGun/Resources/right.png b/ProjectAntiAirCraftGun/Resources/right.png similarity index 100% rename from AntiAircraftGun/Resources/right.png rename to ProjectAntiAirCraftGun/Resources/right.png diff --git a/AntiAircraftGun/Resources/top.png b/ProjectAntiAirCraftGun/Resources/top.png similarity index 100% rename from AntiAircraftGun/Resources/top.png rename to ProjectAntiAirCraftGun/Resources/top.png