diff --git a/Stormtrooper/Stormtrooper/Direction.cs b/Stormtrooper/Stormtrooper/Direction.cs
index 2330eac..35cf926 100644
--- a/Stormtrooper/Stormtrooper/Direction.cs
+++ b/Stormtrooper/Stormtrooper/Direction.cs
@@ -9,7 +9,7 @@ namespace Stormtrooper
///
/// Направление перемещения
///
- internal enum Direction
+ public enum Direction
{
None = 0,
Up = 1,
diff --git a/Stormtrooper/Stormtrooper/Drawning.cs b/Stormtrooper/Stormtrooper/Drawning.cs
index 000a1d3..474ae3a 100644
--- a/Stormtrooper/Stormtrooper/Drawning.cs
+++ b/Stormtrooper/Stormtrooper/Drawning.cs
@@ -12,7 +12,7 @@ namespace Stormtrooper
///
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
///
- internal class Drawning
+ public class Drawning
{
public EntityStormtrooper Storm { get; protected set; }
///
diff --git a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs
index 0d0be1f..aef3d43 100644
--- a/Stormtrooper/Stormtrooper/EntityStormtrooper.cs
+++ b/Stormtrooper/Stormtrooper/EntityStormtrooper.cs
@@ -9,7 +9,7 @@ namespace Stormtrooper
///
/// Класс-сущность "Штурмовик"
///
- internal class EntityStormtrooper
+ public class EntityStormtrooper
{
///
/// Скорость
diff --git a/Stormtrooper/Stormtrooper/FormMap.Designer.cs b/Stormtrooper/Stormtrooper/FormMap.Designer.cs
deleted file mode 100644
index 3ca409c..0000000
--- a/Stormtrooper/Stormtrooper/FormMap.Designer.cs
+++ /dev/null
@@ -1,222 +0,0 @@
-namespace Stormtrooper
-{
- 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.pictureBoxStormtrooper = 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.pictureBoxStormtrooper)).BeginInit();
- this.statusStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // pictureBoxStormtrooper
- //
- this.pictureBoxStormtrooper.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxStormtrooper.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.pictureBoxStormtrooper.Name = "pictureBoxStormtrooper";
- this.pictureBoxStormtrooper.Size = new System.Drawing.Size(1000, 500);
- this.pictureBoxStormtrooper.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxStormtrooper.TabIndex = 0;
- this.pictureBoxStormtrooper.TabStop = false;
- //
- // statusStrip
- //
- this.statusStrip.ImageScalingSize = new System.Drawing.Size(20, 20);
- this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelBodyColor});
- this.statusStrip.Location = new System.Drawing.Point(0, 501);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0);
- this.statusStrip.Size = new System.Drawing.Size(1000, 26);
- this.statusStrip.TabIndex = 1;
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(76, 20);
- this.toolStripStatusLabelSpeed.Text = "Скорость:";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(36, 20);
- this.toolStripStatusLabelWeight.Text = "Вес:";
- //
- // toolStripStatusLabelBodyColor
- //
- this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(45, 20);
- 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(14, 447);
- this.buttonCreate.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(86, 31);
- 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::Stormtrooper.Properties.Resources.arrowUp;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(901, 389);
- this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(34, 40);
- this.buttonUp.TabIndex = 6;
- this.buttonUp.Text = "\r\n";
- 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::Stormtrooper.Properties.Resources.arrowLeft;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(856, 437);
- this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(34, 40);
- this.buttonLeft.TabIndex = 4;
- this.buttonLeft.Text = "\r\n";
- 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::Stormtrooper.Properties.Resources.arrowRight;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(944, 437);
- this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(34, 40);
- this.buttonRight.TabIndex = 3;
- this.buttonRight.Text = "\r\n";
- 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::Stormtrooper.Properties.Resources.arrowDown;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(901, 437);
- this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(34, 40);
- this.buttonDown.TabIndex = 5;
- this.buttonDown.Text = "\r\n";
- 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(116, 447);
- this.buttonCreateModif.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.buttonCreateModif.Name = "buttonCreateModif";
- this.buttonCreateModif.Size = new System.Drawing.Size(126, 31);
- 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(14, 13);
- this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(138, 28);
- this.comboBoxSelectorMap.TabIndex = 8;
- this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
- //
- // FormMap
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(1000, 527);
- 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.pictureBoxStormtrooper);
- this.Controls.Add(this.statusStrip);
- this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
- this.Name = "FormMap";
- this.Text = "Карта";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
- private PictureBox pictureBoxStormtrooper;
- 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/Stormtrooper/Stormtrooper/FormMap.cs b/Stormtrooper/Stormtrooper/FormMap.cs
deleted file mode 100644
index c87fe12..0000000
--- a/Stormtrooper/Stormtrooper/FormMap.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Stormtrooper
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- }
- ///
- /// Заполнение информации по объекту
- ///
- ///
- private void SetData(Drawning storm)
- {
- toolStripStatusLabelSpeed.Text = $"Скорость: {storm.Storm.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {storm.Storm.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет: {storm.Storm.BodyColor.Name}";
- pictureBoxStormtrooper.Image = _abstractMap.CreateMap(pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height, new DrawningObjectStorm(storm));
- }
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var storm = new Drawning(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(storm);
- }
- ///
- /// Перемещение
- ///
- ///
- ///
- 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;
- }
- pictureBoxStormtrooper.Image = _abstractMap?.MoveObject(dir);
- }
-
- ///
- /// Обработка нажатия кнопки "Модификация"
- ///
- ///
- ///
- private void ButtonCreateModif_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var storm = new DrawningMilitary(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)), Convert.ToBoolean(rnd.Next(0, 2)));
- SetData(storm);
- }
-
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Ясное небо":
- _abstractMap = new SecondMap();
- break;
- case "Пасмурное небо":
- _abstractMap = new ThirdMap();
- break;
- }
-
- }
- }
-}
diff --git a/Stormtrooper/Stormtrooper/FormMap.resx b/Stormtrooper/Stormtrooper/FormMap.resx
deleted file mode 100644
index 30aae67..0000000
--- a/Stormtrooper/Stormtrooper/FormMap.resx
+++ /dev/null
@@ -1,66 +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
-
-
- 17, 17
-
-
- 25
-
-
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs
new file mode 100644
index 0000000..5424d44
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.Designer.cs
@@ -0,0 +1,230 @@
+namespace Stormtrooper
+{
+ partial class FormMapWithSetStormtroopers
+ {
+ ///
+ /// 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.groupBoxTools = new System.Windows.Forms.GroupBox();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonRemoveStorm = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonAddStorm = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBoxTools.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBoxTools
+ //
+ this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBoxTools.Controls.Add(this.buttonRemoveStorm);
+ this.groupBoxTools.Controls.Add(this.buttonShowStorage);
+ this.groupBoxTools.Controls.Add(this.buttonDown);
+ this.groupBoxTools.Controls.Add(this.buttonRight);
+ this.groupBoxTools.Controls.Add(this.buttonLeft);
+ this.groupBoxTools.Controls.Add(this.buttonUp);
+ this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
+ this.groupBoxTools.Controls.Add(this.buttonAddStorm);
+ this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBoxTools.Location = new System.Drawing.Point(927, 0);
+ this.groupBoxTools.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.groupBoxTools.Name = "groupBoxTools";
+ this.groupBoxTools.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.groupBoxTools.Size = new System.Drawing.Size(233, 739);
+ this.groupBoxTools.TabIndex = 0;
+ this.groupBoxTools.TabStop = false;
+ this.groupBoxTools.Text = "Инструменты";
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 221);
+ this.maskedTextBoxPosition.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(199, 27);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ this.maskedTextBoxPosition.ValidatingType = typeof(int);
+ //
+ // buttonRemoveStorm
+ //
+ this.buttonRemoveStorm.Location = new System.Drawing.Point(19, 260);
+ this.buttonRemoveStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonRemoveStorm.Name = "buttonRemoveStorm";
+ this.buttonRemoveStorm.Size = new System.Drawing.Size(200, 47);
+ this.buttonRemoveStorm.TabIndex = 3;
+ this.buttonRemoveStorm.Text = "Удалить самолёт";
+ this.buttonRemoveStorm.UseVisualStyleBackColor = true;
+ this.buttonRemoveStorm.Click += new System.EventHandler(this.ButtonRemoveStorm_Click);
+ //
+ // buttonShowStorage
+ //
+ this.buttonShowStorage.Location = new System.Drawing.Point(19, 383);
+ this.buttonShowStorage.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(200, 47);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonDown.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowDown;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(104, 672);
+ this.buttonDown.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(34, 40);
+ this.buttonDown.TabIndex = 10;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.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::Stormtrooper.Properties.Resources.arrowRight;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(145, 672);
+ this.buttonRight.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(34, 40);
+ this.buttonRight.TabIndex = 9;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.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::Stormtrooper.Properties.Resources.arrowLeft;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(63, 672);
+ this.buttonLeft.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(34, 40);
+ this.buttonLeft.TabIndex = 8;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonUp
+ //
+ this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonUp.BackgroundImage = global::Stormtrooper.Properties.Resources.arrowUp;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(104, 624);
+ this.buttonUp.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(34, 40);
+ this.buttonUp.TabIndex = 7;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(19, 521);
+ this.buttonShowOnMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(200, 47);
+ this.buttonShowOnMap.TabIndex = 5;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
+ //
+ // buttonAddStorm
+ //
+ this.buttonAddStorm.Location = new System.Drawing.Point(19, 141);
+ this.buttonAddStorm.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.buttonAddStorm.Name = "buttonAddStorm";
+ this.buttonAddStorm.Size = new System.Drawing.Size(200, 47);
+ this.buttonAddStorm.TabIndex = 1;
+ this.buttonAddStorm.Text = "Добавить самолёт";
+ this.buttonAddStorm.UseVisualStyleBackColor = true;
+ this.buttonAddStorm.Click += new System.EventHandler(this.ButtonAddStorm_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(19, 43);
+ this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(199, 28);
+ this.comboBoxSelectorMap.TabIndex = 0;
+ this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
+ //
+ // pictureBox
+ //
+ this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pictureBox.Location = new System.Drawing.Point(0, 0);
+ this.pictureBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.pictureBox.Name = "pictureBox";
+ this.pictureBox.Size = new System.Drawing.Size(927, 739);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetStormtroopers
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(1160, 739);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBoxTools);
+ this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
+ this.Name = "FormMapWithSetStormtroopers";
+ this.Text = "Карта с набором объектов";
+ this.groupBoxTools.ResumeLayout(false);
+ this.groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+ }
+
+ #endregion
+ private GroupBox groupBoxTools;
+ private PictureBox pictureBox;
+ private ComboBox comboBoxSelectorMap;
+ private Button buttonShowOnMap;
+ private Button buttonAddStorm;
+ private Button buttonDown;
+ private Button buttonRight;
+ private Button buttonLeft;
+ private Button buttonUp;
+ private Button buttonShowStorage;
+ private Button buttonRemoveStorm;
+ private MaskedTextBox maskedTextBoxPosition;
+ }
+}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs
new file mode 100644
index 0000000..8398f1e
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.cs
@@ -0,0 +1,166 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace Stormtrooper
+{
+ public partial class FormMapWithSetStormtroopers : Form
+ {
+ ///
+ /// Объект от класса карты с набором объектов
+ ///
+ private MapWithSetStormtroopersGeneric _mapStormtroopersCollectionGeneric;
+ ///
+ /// Конструктор
+ ///
+ public FormMapWithSetStormtroopers()
+ {
+ InitializeComponent(); ;
+ }
+ ///
+ /// Выбор карты
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Ясное небо":
+ map = new SecondMap();
+ break;
+ case "Пасмурное небо":
+ map = new ThirdMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapStormtroopersCollectionGeneric = new MapWithSetStormtroopersGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapStormtroopersCollectionGeneric = null;
+ }
+ }
+ ///
+ /// Добавление объекта
+ ///
+ ///
+ ///
+ private void ButtonAddStorm_Click(object sender, EventArgs e)
+ {
+ if (_mapStormtroopersCollectionGeneric == null)
+ {
+ return;
+ }
+ FormStormtrooper form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawningObjectStorm car = new(form.SelectedStormtrooper);
+ if ((_mapStormtroopersCollectionGeneric + car) != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveStorm_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(maskedTextBoxPosition.Text))
+ {
+ return;
+ }
+ if (MessageBox.Show("Удалить объект?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
+ {
+ return;
+ }
+ int pos = Convert.ToInt32(maskedTextBoxPosition.Text);
+ if ((_mapStormtroopersCollectionGeneric - pos) != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Вывод набора
+ ///
+ ///
+ ///
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapStormtroopersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowSet();
+ }
+ ///
+ /// Вывод карты
+ ///
+ ///
+ ///
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapStormtroopersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapStormtroopersCollectionGeneric.ShowOnMap();
+ }
+ ///
+ /// Перемещение
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapStormtroopersCollectionGeneric == null)
+ {
+ return;
+ }
+ //получаем имя кнопки
+ 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;
+ }
+ pictureBox.Image = _mapStormtroopersCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/FormMapWithSetStormtroopers.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 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/Stormtrooper/Stormtrooper/FormStormtrooper.Designer.cs b/Stormtrooper/Stormtrooper/FormStormtrooper.Designer.cs
index 661a1a1..17d5261 100644
--- a/Stormtrooper/Stormtrooper/FormStormtrooper.Designer.cs
+++ b/Stormtrooper/Stormtrooper/FormStormtrooper.Designer.cs
@@ -39,6 +39,7 @@
this.buttonDown = new System.Windows.Forms.Button();
this.buttonUp = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
+ this.buttonSelectStorm = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxStormtrooper)).BeginInit();
this.statusStrip1.SuspendLayout();
this.SuspendLayout();
@@ -159,11 +160,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
//
+ // buttonSelectStorm
+ //
+ this.buttonSelectStorm.Location = new System.Drawing.Point(260, 396);
+ this.buttonSelectStorm.Name = "buttonSelectStorm";
+ this.buttonSelectStorm.Size = new System.Drawing.Size(94, 29);
+ this.buttonSelectStorm.TabIndex = 8;
+ this.buttonSelectStorm.Text = "Выбрать";
+ this.buttonSelectStorm.UseVisualStyleBackColor = true;
+ this.buttonSelectStorm.Click += new System.EventHandler(this.ButtonSelectStorm_Click);
+ //
// FormStormtrooper
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(831, 461);
+ this.Controls.Add(this.buttonSelectStorm);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonUp);
this.Controls.Add(this.buttonDown);
@@ -195,5 +207,6 @@
private Button buttonDown;
private Button buttonUp;
private Button buttonCreateModif;
+ private Button buttonSelectStorm;
}
}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/FormStormtrooper.cs b/Stormtrooper/Stormtrooper/FormStormtrooper.cs
index 1479266..9af2922 100644
--- a/Stormtrooper/Stormtrooper/FormStormtrooper.cs
+++ b/Stormtrooper/Stormtrooper/FormStormtrooper.cs
@@ -4,6 +4,11 @@ namespace Stormtrooper
{
private Drawning _storm;
+ ///
+ ///
+ ///
+ public Drawning SelectedStormtrooper { get; private set; }
+
public FormStormtrooper()
{
InitializeComponent();
@@ -38,7 +43,13 @@ namespace Stormtrooper
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _storm = new Drawning(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
+ Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ color = dialog.Color;
+ }
+ _storm = new Drawning(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
SetData();
Draw();
}
@@ -94,5 +105,11 @@ namespace Stormtrooper
SetData();
Draw();
}
+
+ private void ButtonSelectStorm_Click(object sender, EventArgs e)
+ {
+ SelectedStormtrooper = _storm;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/MapWithSetStormtroopersGeneric.cs b/Stormtrooper/Stormtrooper/MapWithSetStormtroopersGeneric.cs
new file mode 100644
index 0000000..8538fbf
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/MapWithSetStormtroopersGeneric.cs
@@ -0,0 +1,186 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ ///
+ /// Карта с набром объектов под нее
+ ///
+ ///
+ ///
+ internal class MapWithSetStormtroopersGeneric
+ where T : class, IDrawningObject
+ where U : AbstractMap
+ {
+ ///
+ /// Ширина окна отрисовки
+ ///
+ private readonly int _pictureWidth;
+ ///
+ /// Высота окна отрисовки
+ ///
+ private readonly int _pictureHeight;
+ ///
+ /// Размер занимаемого объектом места (ширина)
+ ///
+ private readonly int _placeSizeWidth = 135;
+ ///
+ /// Размер занимаемого объектом места (высота)
+ ///
+ private readonly int _placeSizeHeight = 100;
+ ///
+ /// Набор объектов
+ ///
+ private readonly SetStormtroopersGeneric _setStormtroopers;
+ ///
+ /// Карта
+ ///
+ private readonly U _map;
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public MapWithSetStormtroopersGeneric(int picWidth, int picHeight, U map)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _map = map;
+ _setStormtroopers = new SetStormtroopersGeneric(width * height);
+ }
+ ///
+ /// Перегрузка оператора сложения
+ ///
+ ///
+ ///
+ ///
+ public static int operator +(MapWithSetStormtroopersGeneric map, T stormtrooper)
+ {
+ return map._setStormtroopers.Insert(stormtrooper);
+ }
+ ///
+ /// Перегрузка оператора вычитания
+ ///
+ ///
+ ///
+ ///
+ public static T operator -(MapWithSetStormtroopersGeneric map, int
+ position)
+ {
+ return map._setStormtroopers.Remove(position);
+ }
+ ///
+ /// Вывод всего набора объектов
+ ///
+ ///
+ public Bitmap ShowSet()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawStormtroopers(gr);
+ return bmp;
+ }
+ ///
+ /// Просмотр объекта на карте
+ ///
+ ///
+ public Bitmap ShowOnMap()
+ {
+ Shaking();
+ for (int i = 0; i < _setStormtroopers.Count; i++)
+ {
+ var car = _setStormtroopers.Get(i);
+ if (car != null)
+ {
+ return _map.CreateMap(_pictureWidth, _pictureHeight, car);
+ }
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+ ///
+ /// Перемещение объекта по крате
+ ///
+ ///
+ ///
+ public Bitmap MoveObject(Direction direction)
+ {
+ if (_map != null)
+ {
+ return _map.MoveObject(direction);
+ }
+ return new(_pictureWidth, _pictureHeight);
+ }
+ ///
+ /// "Взбалтываем" набор, чтобы все элементы оказались в начале
+ ///
+ private void Shaking()
+ {
+ int j = _setStormtroopers.Count - 1;
+ for (int i = 0; i < _setStormtroopers.Count; i++)
+ {
+ if (_setStormtroopers.Get(i) == null)
+ {
+ for (; j > i; j--)
+ {
+ var car = _setStormtroopers.Get(j);
+ if (car != null)
+ {
+ _setStormtroopers.Insert(car, i);
+ _setStormtroopers.Remove(j);
+ break;
+ }
+ }
+ if (j <= i)
+ {
+ return;
+ }
+ }
+ }
+ }
+ ///
+ /// Метод отрисовки фона
+ ///
+ ///
+ private void DrawBackground(Graphics g)
+ {
+ Brush br = new SolidBrush(Color.Gray);
+ g.FillRectangle(br, new Rectangle(0, 0, _pictureWidth, _pictureHeight));
+ Pen pen = new(Color.White, 3);
+ pen.DashStyle = DashStyle.Dash;
+ for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
+ {
+ for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
+ {//линия рамзетки места
+ g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i *
+ _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
+ }
+ g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
+ (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
+ }
+ }
+ ///
+ /// Метод прорисовки объектов
+ ///
+ ///
+ private void DrawStormtroopers(Graphics g)
+ {
+ int numOfObjectsInRow = _pictureWidth / _placeSizeWidth;
+ int i = 0;
+ for (int j = 0; j < _setStormtroopers.Count; j++)
+ {
+ _setStormtroopers.Get(i)?.SetObject((numOfObjectsInRow - (i % numOfObjectsInRow) - 1) * _placeSizeWidth, (i / numOfObjectsInRow) * _placeSizeHeight + _placeSizeHeight, _pictureWidth, _pictureHeight);
+ _setStormtroopers.Get(i)?.DrawningObject(g);
+ i++;
+ }
+
+ }
+ }
+}
diff --git a/Stormtrooper/Stormtrooper/Program.cs b/Stormtrooper/Stormtrooper/Program.cs
index a5278ed..f31027b 100644
--- a/Stormtrooper/Stormtrooper/Program.cs
+++ b/Stormtrooper/Stormtrooper/Program.cs
@@ -11,7 +11,7 @@ namespace Stormtrooper
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
- Application.Run(new FormMap());
+ Application.Run(new FormMapWithSetStormtroopers());
}
}
}
\ No newline at end of file
diff --git a/Stormtrooper/Stormtrooper/SetStormtroopersGeneric.cs b/Stormtrooper/Stormtrooper/SetStormtroopersGeneric.cs
new file mode 100644
index 0000000..339a657
--- /dev/null
+++ b/Stormtrooper/Stormtrooper/SetStormtroopersGeneric.cs
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Stormtrooper
+{
+ ///
+ /// Параметризованный набор объектов
+ ///
+ ///
+ internal class SetStormtroopersGeneric
+ where T : class
+ {
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private readonly T[] _places;
+ ///
+ /// Количество объектов в массиве
+ ///
+ public int Count => _places.Length;
+
+ public int TecCount = 0; // текущее количество объектов в массиве
+ ///
+ /// Конструктор
+ ///
+ ///
+ public SetStormtroopersGeneric(int count)
+ {
+ _places = new T[count];
+ }
+ ///
+ /// Добавление объекта в набор
+ ///
+ /// Добавляемый автомобиль
+ ///
+ public int Insert(T stormtrooper)
+ {
+ return Insert(stormtrooper, 0);
+ }
+ ///
+ /// Добавление объекта в набор на конкретную позицию
+ ///
+ /// Добавляемый автомобиль
+ /// Позиция
+ ///
+ public int Insert(T stormtrooper, int position)
+ {
+
+ if (position < 0 || position >= Count || TecCount == Count) return -1;
+
+ TecCount++;
+ while (_places[position] != null)
+ {
+ for (int i = _places.Length - 1; i > 0; --i)
+ {
+ if (_places[i] == null && _places[i - 1] != null)
+ {
+ _places[i] = _places[i - 1];
+ _places[i - 1] = null;
+ }
+ }
+ }
+ _places[position] = stormtrooper;
+ return position;
+ }
+ ///
+ /// Удаление объекта из набора с конкретной позиции
+ ///
+ ///
+ ///
+ public T Remove(int position)
+ {
+ if (position < 0 || position >= _places.Length) return null;
+ T saveStorm = _places[position];
+ _places[position] = null;
+ return saveStorm;
+ }
+ ///
+ /// Получение объекта из набора по позиции
+ ///
+ ///
+ ///
+ public T Get(int position)
+ {
+ if (position < 0 || position >= Count || _places[position] == null) return null;
+ return _places[position];
+ }
+ }
+}