diff --git a/AirFighter/AirFighter/AbstractMap.cs b/AirFighter/AirFighter/AbstractMap.cs
index 2c61fba..21a9d6c 100644
--- a/AirFighter/AirFighter/AbstractMap.cs
+++ b/AirFighter/AirFighter/AbstractMap.cs
@@ -78,9 +78,9 @@ namespace AirFighter
{
return 2;
}
- for (int i = (int)(Top / _size_y); i <= (int)(Bottom / _size_y) + 1; i++)
+ for (int i = (int)(Top / _size_y); i <= (int)(Bottom / _size_y); i++)
{
- for (int j = (int)(Left / _size_x); j <= (int)(Right / _size_x) + 1; j++)
+ for (int j = (int)(Left / _size_x); j <= (int)(Right / _size_x); j++)
{
if (_map[i, j] == _barrier)
return 0;
@@ -106,22 +106,23 @@ namespace AirFighter
int flag = 0;
while (flag == 0)
{
- flag = CheckBarrier((int)Right, (int)Left, (int)Top, (int)Bottom);
+
y += (int)_size_y;
- Top += _size_y;
- Bottom += _size_y;
+ Top += (int)_size_y;
+ Bottom += (int)_size_y;
_drawningObject.SetObject(x, y, _width, _height);
+ flag = CheckBarrier((int)Right, (int)Left, (int)Top, (int)Bottom);
}
if (flag == 1)
{
return true;
}
x += (int)_size_x;
- Left += _size_x;
- Right += _size_x;
+ Left += (int)_size_x;
+ Right += (int)_size_x;
y = (int)tempTop;
- Top = tempTop;
- Bottom = tempBottom;
+ Top = (int)tempTop;
+ Bottom = (int)tempBottom;
}
return false;
}
diff --git a/AirFighter/AirFighter/Direction.cs b/AirFighter/AirFighter/Direction.cs
index b4601d4..9e743fe 100644
--- a/AirFighter/AirFighter/Direction.cs
+++ b/AirFighter/AirFighter/Direction.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Направление перемещения
///
- internal enum Direction
+ public enum Direction
{
None = 0,
Up = 1,
diff --git a/AirFighter/AirFighter/DrawningAirFighter.cs b/AirFighter/AirFighter/DrawningAirFighter.cs
index 12f3ab9..1675837 100644
--- a/AirFighter/AirFighter/DrawningAirFighter.cs
+++ b/AirFighter/AirFighter/DrawningAirFighter.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
///
- internal class DrawningAirFighter
+ public class DrawningAirFighter
{
///
/// Класс-сущность
diff --git a/AirFighter/AirFighter/EntityAirFighter.cs b/AirFighter/AirFighter/EntityAirFighter.cs
index 0aa3e36..688c378 100644
--- a/AirFighter/AirFighter/EntityAirFighter.cs
+++ b/AirFighter/AirFighter/EntityAirFighter.cs
@@ -9,7 +9,7 @@ namespace AirFighter
///
/// Класс-сущность "Военный самолет"
///
- internal class EntityAirFighter
+ public class EntityAirFighter
{
///
/// Скорость
diff --git a/AirFighter/AirFighter/FormAirFighter.Designer.cs b/AirFighter/AirFighter/FormAirFighter.Designer.cs
index b5e7eda..e1176f5 100644
--- a/AirFighter/AirFighter/FormAirFighter.Designer.cs
+++ b/AirFighter/AirFighter/FormAirFighter.Designer.cs
@@ -39,6 +39,7 @@
this.buttonLeft = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonUpgrade = new System.Windows.Forms.Button();
+ this.buttonSelectAirFighter = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -154,11 +155,22 @@
this.buttonUpgrade.UseVisualStyleBackColor = true;
this.buttonUpgrade.Click += new System.EventHandler(this.ButtonUpgrade_Click);
//
+ // buttonSelectAirFighter
+ //
+ this.buttonSelectAirFighter.Location = new System.Drawing.Point(565, 379);
+ this.buttonSelectAirFighter.Name = "buttonSelectAirFighter";
+ this.buttonSelectAirFighter.Size = new System.Drawing.Size(94, 29);
+ this.buttonSelectAirFighter.TabIndex = 8;
+ this.buttonSelectAirFighter.Text = "Выбрать";
+ this.buttonSelectAirFighter.UseVisualStyleBackColor = true;
+ this.buttonSelectAirFighter.Click += new System.EventHandler(this.ButtonSelectAirFighter_Click);
+ //
// FormAirFighter
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSelectAirFighter);
this.Controls.Add(this.buttonUpgrade);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonLeft);
@@ -190,5 +202,6 @@
private Button buttonLeft;
private Button buttonRight;
private Button buttonUpgrade;
+ private Button buttonSelectAirFighter;
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormAirFighter.cs b/AirFighter/AirFighter/FormAirFighter.cs
index 60b932e..a8bec1a 100644
--- a/AirFighter/AirFighter/FormAirFighter.cs
+++ b/AirFighter/AirFighter/FormAirFighter.cs
@@ -3,6 +3,10 @@ namespace AirFighter
public partial class FormAirFighter : Form
{
private DrawningAirFighter _airFighter;
+ ///
+ ///
+ ///
+ public DrawningAirFighter SelectedAirFighter { get ; private set; }
public FormAirFighter()
{
InitializeComponent();
@@ -36,7 +40,13 @@ namespace AirFighter
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random rnd = new Random();
- _airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), 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;
+ }
+ _airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), color);
SetData();
Draw();
}
@@ -83,10 +93,28 @@ namespace AirFighter
private void ButtonUpgrade_Click(object sender, EventArgs e)
{
Random rnd = new();
- _airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), 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)));
+ 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;
+ }
+ Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialogDop = new();
+ if (dialogDop.ShowDialog() == DialogResult.OK)
+ {
+ dopColor = dialogDop.Color;
+ }
+ _airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), color,
+ dopColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
SetData();
Draw();
}
+
+ private void ButtonSelectAirFighter_Click(object sender, EventArgs e)
+ {
+ SelectedAirFighter = _airFighter;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMap.Designer.cs b/AirFighter/AirFighter/FormMap.Designer.cs
deleted file mode 100644
index 26cb86a..0000000
--- a/AirFighter/AirFighter/FormMap.Designer.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-namespace AirFighter
-{
- 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.pictureBoxAirFighter = 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.buttonDown = new System.Windows.Forms.Button();
- this.buttonLeft = new System.Windows.Forms.Button();
- this.buttonRight = new System.Windows.Forms.Button();
- this.buttonUpgrade = new System.Windows.Forms.Button();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).BeginInit();
- this.statusStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // pictureBoxAirFighter
- //
- this.pictureBoxAirFighter.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxAirFighter.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxAirFighter.Name = "pictureBoxAirFighter";
- this.pictureBoxAirFighter.Size = new System.Drawing.Size(800, 424);
- this.pictureBoxAirFighter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxAirFighter.TabIndex = 0;
- this.pictureBoxAirFighter.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, 424);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.Size = new System.Drawing.Size(800, 26);
- this.statusStrip.TabIndex = 1;
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(80, 20);
- this.toolStripStatusLabelSpeed.Text = "Скорость: ";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(40, 20);
- this.toolStripStatusLabelWeight.Text = "Вес: ";
- //
- // toolStripStatusLabelBodyColor
- //
- this.toolStripStatusLabelBodyColor.Name = "toolStripStatusLabelBodyColor";
- this.toolStripStatusLabelBodyColor.Size = new System.Drawing.Size(49, 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(39, 378);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(94, 29);
- 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::AirFighter.Properties.Resources.Up;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(722, 341);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(30, 30);
- this.buttonUp.TabIndex = 3;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonDown
- //
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(722, 377);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(30, 30);
- this.buttonDown.TabIndex = 4;
- this.buttonDown.UseVisualStyleBackColor = true;
- this.buttonDown.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::AirFighter.Properties.Resources.Left;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(686, 377);
- this.buttonLeft.Name = "buttonLeft";
- this.buttonLeft.Size = new System.Drawing.Size(30, 30);
- this.buttonLeft.TabIndex = 5;
- 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::AirFighter.Properties.Resources.Right;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(758, 378);
- this.buttonRight.Name = "buttonRight";
- this.buttonRight.Size = new System.Drawing.Size(30, 30);
- this.buttonRight.TabIndex = 6;
- this.buttonRight.UseVisualStyleBackColor = true;
- this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonUpgrade
- //
- this.buttonUpgrade.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonUpgrade.Location = new System.Drawing.Point(148, 379);
- this.buttonUpgrade.Name = "buttonUpgrade";
- this.buttonUpgrade.Size = new System.Drawing.Size(127, 29);
- this.buttonUpgrade.TabIndex = 7;
- this.buttonUpgrade.Text = "Модификация";
- this.buttonUpgrade.UseVisualStyleBackColor = true;
- this.buttonUpgrade.Click += new System.EventHandler(this.ButtonUpgrade_Click);
- //
- // comboBoxSelectorMap
- //
- this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBoxSelectorMap.FormattingEnabled = true;
- this.comboBoxSelectorMap.Items.AddRange(new object[] {
- "Простая карта",
- "Карта шторма"});
- this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
- this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(151, 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(800, 450);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.buttonUpgrade);
- this.Controls.Add(this.buttonRight);
- this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.buttonDown);
- this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.buttonCreate);
- this.Controls.Add(this.pictureBoxAirFighter);
- this.Controls.Add(this.statusStrip);
- this.Name = "FormMap";
- this.Text = "Карта";
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxAirFighter)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private PictureBox pictureBoxAirFighter;
- private StatusStrip statusStrip;
- private ToolStripStatusLabel toolStripStatusLabelSpeed;
- private ToolStripStatusLabel toolStripStatusLabelWeight;
- private ToolStripStatusLabel toolStripStatusLabelBodyColor;
- private Button buttonCreate;
- private Button buttonUp;
- private Button buttonDown;
- private Button buttonLeft;
- private Button buttonRight;
- private Button buttonUpgrade;
- private ComboBox comboBoxSelectorMap;
- }
-}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMap.cs b/AirFighter/AirFighter/FormMap.cs
deleted file mode 100644
index 551313c..0000000
--- a/AirFighter/AirFighter/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 AirFighter
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- comboBoxSelectorMap.SelectedIndex = 0;
- }
- ///
- /// Заполнение информации по объекту
- ///
- private void SetData(DrawningAirFighter airFighter)
- {
-
- toolStripStatusLabelSpeed.Text = $"Скорость: {airFighter.AirFighter?.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {airFighter.AirFighter?.Weight}";
- toolStripStatusLabelBodyColor.Text = $"Цвет: {airFighter.AirFighter?.BodyColor}";
- pictureBoxAirFighter.Image = _abstractMap.CreateMap(pictureBoxAirFighter.Width, pictureBoxAirFighter.Height,
- new DrawningObjectAirFighter(airFighter));
- }
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
-
- Random rnd = new Random();
- var _airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(_airFighter);
- }
-
- ///
- /// Обработка нажатий кнопок перемещения
- ///
- ///
- ///
- 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;
- }
- pictureBoxAirFighter.Image = _abstractMap?.MoveObject(dir);
- }
- ///
- /// Обработка нажатия кнопки "Модификация"
- ///
- ///
- ///
- private void ButtonUpgrade_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var _airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
- SetData(_airFighter);
- }
- ///
- /// Изменение карты
- ///
- ///
- ///
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Карта шторма":
- _abstractMap = new StormMap();
- break;
- }
- }
- }
-}
diff --git a/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs b/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs
new file mode 100644
index 0000000..d4ce11e
--- /dev/null
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.Designer.cs
@@ -0,0 +1,212 @@
+namespace AirFighter
+{
+ partial class FormMapWithSetAirFighters
+ {
+ ///
+ /// 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.groupBox = new System.Windows.Forms.GroupBox();
+ this.buttonUp = new System.Windows.Forms.Button();
+ this.buttonDown = new System.Windows.Forms.Button();
+ this.buttonLeft = new System.Windows.Forms.Button();
+ this.buttonRight = new System.Windows.Forms.Button();
+ this.buttonShowOnMap = new System.Windows.Forms.Button();
+ this.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveAirFighter = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddAirFighter = new System.Windows.Forms.Button();
+ this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
+ this.pictureBox = new System.Windows.Forms.PictureBox();
+ this.groupBox.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox
+ //
+ this.groupBox.Controls.Add(this.buttonUp);
+ this.groupBox.Controls.Add(this.buttonDown);
+ this.groupBox.Controls.Add(this.buttonLeft);
+ this.groupBox.Controls.Add(this.buttonRight);
+ this.groupBox.Controls.Add(this.buttonShowOnMap);
+ this.groupBox.Controls.Add(this.buttonShowStorage);
+ this.groupBox.Controls.Add(this.buttonRemoveAirFighter);
+ this.groupBox.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBox.Controls.Add(this.buttonAddAirFighter);
+ this.groupBox.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBox.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBox.Location = new System.Drawing.Point(550, 0);
+ this.groupBox.Name = "groupBox";
+ this.groupBox.Size = new System.Drawing.Size(250, 450);
+ this.groupBox.TabIndex = 0;
+ this.groupBox.TabStop = false;
+ this.groupBox.Text = "Инструменты";
+ //
+ // buttonUp
+ //
+ this.buttonUp.BackgroundImage = global::AirFighter.Properties.Resources.Up;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(135, 370);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ this.buttonUp.TabIndex = 2;
+ this.buttonUp.UseVisualStyleBackColor = true;
+ this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonDown
+ //
+ this.buttonDown.BackgroundImage = global::AirFighter.Properties.Resources.Down;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(135, 408);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 3;
+ this.buttonDown.UseVisualStyleBackColor = true;
+ this.buttonDown.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonLeft
+ //
+ this.buttonLeft.BackgroundImage = global::AirFighter.Properties.Resources.Left;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(99, 408);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ this.buttonLeft.TabIndex = 4;
+ this.buttonLeft.UseVisualStyleBackColor = true;
+ this.buttonLeft.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonRight
+ //
+ this.buttonRight.BackgroundImage = global::AirFighter.Properties.Resources.Right;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(171, 408);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 5;
+ this.buttonRight.UseVisualStyleBackColor = true;
+ this.buttonRight.Click += new System.EventHandler(this.ButtonMove_Click);
+ //
+ // buttonShowOnMap
+ //
+ this.buttonShowOnMap.Location = new System.Drawing.Point(28, 296);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(210, 29);
+ this.buttonShowOnMap.TabIndex = 5;
+ this.buttonShowOnMap.Text = "Посмотреть карту";
+ this.buttonShowOnMap.UseVisualStyleBackColor = true;
+ this.buttonShowOnMap.Click += new System.EventHandler(this.ButtonShowOnMap_Click);
+ //
+ // buttonShowStorage
+ //
+ this.buttonShowStorage.Location = new System.Drawing.Point(28, 252);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(210, 29);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonRemoveAirFighter
+ //
+ this.buttonRemoveAirFighter.Location = new System.Drawing.Point(28, 194);
+ this.buttonRemoveAirFighter.Name = "buttonRemoveAirFighter";
+ this.buttonRemoveAirFighter.Size = new System.Drawing.Size(210, 29);
+ this.buttonRemoveAirFighter.TabIndex = 3;
+ this.buttonRemoveAirFighter.Text = "Удалить самолет";
+ this.buttonRemoveAirFighter.UseVisualStyleBackColor = true;
+ this.buttonRemoveAirFighter.Click += new System.EventHandler(this.ButtonRemoveAirFighter_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(28, 145);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(210, 27);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ //
+ // buttonAddAirFighter
+ //
+ this.buttonAddAirFighter.Location = new System.Drawing.Point(28, 96);
+ this.buttonAddAirFighter.Name = "buttonAddAirFighter";
+ this.buttonAddAirFighter.Size = new System.Drawing.Size(210, 29);
+ this.buttonAddAirFighter.TabIndex = 1;
+ this.buttonAddAirFighter.Text = "Добавить самолет";
+ this.buttonAddAirFighter.UseVisualStyleBackColor = true;
+ this.buttonAddAirFighter.Click += new System.EventHandler(this.ButtonAddAirFighter_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(28, 45);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(210, 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.Name = "pictureBox";
+ this.pictureBox.Size = new System.Drawing.Size(550, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetAirFighters
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBox);
+ this.Name = "FormMapWithSetAirFighters";
+ this.Text = "FormMapWithSetAirFighters";
+ this.groupBox.ResumeLayout(false);
+ this.groupBox.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBox;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private Button buttonRemoveAirFighter;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonAddAirFighter;
+ private ComboBox comboBoxSelectorMap;
+ private PictureBox pictureBox;
+ private Button buttonUp;
+ private Button buttonDown;
+ private Button buttonLeft;
+ private Button buttonRight;
+ }
+}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/FormMapWithSetAirFighters.cs b/AirFighter/AirFighter/FormMapWithSetAirFighters.cs
new file mode 100644
index 0000000..0694cf9
--- /dev/null
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.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;
+using static System.Windows.Forms.DataFormats;
+
+namespace AirFighter
+{
+ public partial class FormMapWithSetAirFighters : Form
+ {
+ ///
+ /// Объект от класса карты с набором объектов
+ ///
+ private MapWithSetAirFightersGeneric _mapAirFightersCollectionGeneric;
+ ///
+ /// Конструктор
+ public FormMapWithSetAirFighters()
+ {
+ InitializeComponent();
+ }
+ ///
+ /// Выбор карты
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender,
+ EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Карта шторма":
+ map = new StormMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapAirFightersCollectionGeneric = new
+ MapWithSetAirFightersGeneric(
+ pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapAirFightersCollectionGeneric = null;
+ }
+ }
+ ///
+ /// Добавление объекта
+ ///
+ ///
+ ///
+ private void ButtonAddAirFighter_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ FormAirFighter form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawningObjectAirFighter airFighter = new(form.SelectedAirFighter);
+ if ((_mapAirFightersCollectionGeneric + airFighter) == 0)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveAirFighter_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 ((_mapAirFightersCollectionGeneric - pos) != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Вывод набора
+ ///
+ ///
+ ///
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowSet();
+ }
+ ///
+ /// Вывод карты
+ ///
+ ///
+ ///
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapAirFightersCollectionGeneric.ShowOnMap();
+ }
+ ///
+ /// Перемещение
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapAirFightersCollectionGeneric == 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 = _mapAirFightersCollectionGeneric.MoveObject(dir);
+ }
+ }
+}
diff --git a/AirFighter/AirFighter/FormMap.resx b/AirFighter/AirFighter/FormMapWithSetAirFighters.resx
similarity index 93%
rename from AirFighter/AirFighter/FormMap.resx
rename to AirFighter/AirFighter/FormMapWithSetAirFighters.resx
index 2c0949d..f298a7b 100644
--- a/AirFighter/AirFighter/FormMap.resx
+++ b/AirFighter/AirFighter/FormMapWithSetAirFighters.resx
@@ -57,7 +57,4 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
- 17, 17
-
\ No newline at end of file
diff --git a/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs b/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs
new file mode 100644
index 0000000..3f8684e
--- /dev/null
+++ b/AirFighter/AirFighter/MapWithSetAirFightersGeneric.cs
@@ -0,0 +1,203 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace AirFighter
+{
+ ///
+ /// Карта с набром объектов под нее
+ ///
+ ///
+ ///
+ internal class MapWithSetAirFightersGeneric
+ where T : class, IDrawningObject
+ where U : AbstractMap
+ {
+ ///
+ /// Ширина окна отрисовки
+ ///
+ private readonly int _pictureWidth;
+ ///
+ /// Высота окна отрисовки
+ ///
+ private readonly int _pictureHeight;
+ ///
+ /// Размер занимаемого объектом места (ширина)
+ ///
+ private readonly int _placeSizeWidth = 210;
+ ///
+ /// Размер занимаемого объектом места (высота)
+ ///
+ private readonly int _placeSizeHeight = 90;
+ ///
+ /// Набор объектов
+ ///
+ private readonly SetAirFightersGeneric _setAirFighters;
+ ///
+ /// Карта
+ ///
+ private readonly U _map;
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public MapWithSetAirFightersGeneric(int picWidth, int picHeight, U map)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _setAirFighters = new SetAirFightersGeneric(width * height);
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _map = map;
+ }
+ ///
+ /// Перегрузка оператора сложения
+ ///
+ ///
+ ///
+ ///
+ public static int operator +(MapWithSetAirFightersGeneric map, T airFighter)
+ {
+ return map._setAirFighters.Insert(airFighter);
+ }
+ ///
+ /// Перегрузка оператора вычитания
+ ///
+ ///
+ ///
+ ///
+ public static T operator -(MapWithSetAirFightersGeneric map, int
+ position)
+ {
+ return map._setAirFighters.Remove(position);
+ }
+ ///
+ /// Вывод всего набора объектов
+ ///
+ ///
+ public Bitmap ShowSet()
+ {
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawAirFighters(gr);
+ return bmp;
+ }
+ ///
+ /// Просмотр объекта на карте
+ ///
+ ///
+ public Bitmap ShowOnMap()
+ {
+ Shaking();
+ for (int i = 0; i < _setAirFighters.Count; i++)
+ {
+ var airFighter = _setAirFighters.Get(i);
+ if (airFighter != null)
+ {
+ return _map.CreateMap(_pictureWidth, _pictureHeight, airFighter);
+ }
+ }
+ 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 = _setAirFighters.Count - 1;
+ for (int i = 0; i < _setAirFighters.Count; i++)
+ {
+ if (_setAirFighters.Get(i) == null)
+ {
+ for (; j > i; j--)
+ {
+ var airFighter = _setAirFighters.Get(j);
+ if (airFighter != null)
+ {
+ _setAirFighters.Insert(airFighter, i);
+ _setAirFighters.Remove(j);
+ break;
+ }
+ }
+ if (j <= i)
+ {
+ return;
+ }
+ }
+ }
+ }
+ ///
+ /// Метод отрисовки фона
+ ///
+ ///
+ private void DrawBackground(Graphics g)
+ {
+ Pen pen = new(Color.Black, 3);
+ 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.FillPolygon(new SolidBrush(Color.Gray), new PointF[]
+ {
+ new Point(i * _placeSizeWidth + _placeSizeWidth / 5, j * _placeSizeHeight + _placeSizeHeight / 10),
+ new Point((i + 1) * _placeSizeWidth - _placeSizeWidth / 5, j * _placeSizeHeight + _placeSizeHeight / 10),
+ new Point((i + 1) * _placeSizeWidth - _placeSizeWidth / 5, (j + 1) * _placeSizeHeight - _placeSizeHeight / 10),
+ new Point(i * _placeSizeWidth + _placeSizeWidth / 5, (j + 1) * _placeSizeHeight - _placeSizeHeight / 10),
+ });
+ }
+ g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth,
+ (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
+ }
+ }
+ ///
+ /// Метод прорисовки объектов
+ ///
+ ///
+ private void DrawAirFighters(Graphics g)
+ {
+ int currentWidth = _pictureWidth / _placeSizeWidth - 1;
+ int currentHeight = _pictureHeight / _placeSizeHeight - 1;
+
+ for (int i = 0; i < _setAirFighters.Count; i++)
+ {
+ _setAirFighters.Get(i)?.SetObject(currentWidth * _placeSizeWidth + 50, currentHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
+ _setAirFighters.Get(i)?.DrawningObject(g);
+
+ if(currentWidth > 0)
+ {
+ currentWidth -= 1;
+ }
+ else
+ {
+ if(currentHeight > 0)
+ {
+ currentHeight -= 1;
+ currentWidth = _pictureWidth / _placeSizeWidth - 1;
+ }else return;
+ }
+ }
+ }
+
+ }
+}
diff --git a/AirFighter/AirFighter/Program.cs b/AirFighter/AirFighter/Program.cs
index b613151..f61e6a6 100644
--- a/AirFighter/AirFighter/Program.cs
+++ b/AirFighter/AirFighter/Program.cs
@@ -11,7 +11,7 @@ namespace AirFighter
// 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 FormMapWithSetAirFighters());
}
}
}
\ No newline at end of file
diff --git a/AirFighter/AirFighter/SetAirFightersGeneric.cs b/AirFighter/AirFighter/SetAirFightersGeneric.cs
new file mode 100644
index 0000000..4496e04
--- /dev/null
+++ b/AirFighter/AirFighter/SetAirFightersGeneric.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms.VisualStyles;
+
+namespace AirFighter
+{
+ ///
+ /// Параметризованный набор объектов
+ ///
+ ///
+ internal class SetAirFightersGeneric
+ where T: class
+ {
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private readonly T[] _places;
+ ///
+ /// Количество объектов в массиве
+ ///
+ public int Count => _places.Length;
+ ///
+ /// Конструктор
+ ///
+ ///
+ public SetAirFightersGeneric(int count)
+ {
+ _places = new T[count];
+ }
+ ///
+ /// Проверка на наличие пустых мест
+ ///
+ ///
+ ///
+ private bool CheckNullPosition(int firstIndex)
+ {
+ if(firstIndex >= _places.Length && firstIndex < 0)
+ {
+ return false;
+ }
+ for(int i = firstIndex; i < _places.Length; i++)
+ {
+ if(_places[i] == null)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ ///
+ /// Добавление объекта в набор
+ ///
+ /// Добавляемый автомобиль
+ ///
+ public int Insert(T airFighter)
+ {
+ return Insert(airFighter, 0);
+ }
+ ///
+ /// Добавление объекта в набор на конкретную позицию
+ ///
+ /// Добавляемый автомобиль
+ /// Позиция
+ ///
+ public int Insert(T airFighter, int position)
+ {
+ if(airFighter == null)
+ {
+ return -1;
+ }
+ if (_places[position] == null)
+ {
+ _places[position] = airFighter;
+ }
+ else
+ {
+ if(CheckNullPosition(position + 1))
+ {
+ T tempMain = airFighter;
+ for (int i = position; i < _places.Length; i++)
+ {
+ if (_places[i] == null)
+ {
+ _places[i] = tempMain;
+ break;
+ }
+ else
+ {
+ T temp2 = _places[i];
+ _places[i] = tempMain;
+ tempMain = temp2;
+ }
+ }
+ }
+ else
+ {
+ return -1;
+ }
+ }
+ return position;
+ }
+ ///
+ /// Удаление объекта из набора с конкретной позиции
+ ///
+ ///
+ ///
+ public T Remove(int position)
+ {
+ if (position >= 0 && position < _places.Length && _places[position] != null)
+ {
+ T temp = _places[position];
+ _places[position] = null;
+ return temp;
+ }
+ else
+ return null;
+ }
+ ///
+ /// Получение объекта из набора по позиции
+ ///
+ ///
+ ///
+ public T Get(int position)
+ {
+ if (_places[position] != null)
+ {
+ return _places[position];
+ }
+ else
+ return null;
+ }
+}
+}