diff --git a/Ship/Ship/AbstractMap.cs b/Ship/Ship/AbstractMap.cs
index 5de5a27..fe8056a 100644
--- a/Ship/Ship/AbstractMap.cs
+++ b/Ship/Ship/AbstractMap.cs
@@ -56,17 +56,14 @@ namespace Ship
private bool ObjectIntersects()
{
var location = _drawingObject.GetCurrentPosition();
- Debug.WriteLine(location.Left + " " + location.Right + " " + location.Top + " " + location.Bottom);
for (int i = 0; i < _map.GetLength(0); i++)
{
for (int j = 0; j < _map.GetLength(1); j++)
{
if (_map[i, j] == _barrier)
{
- Debug.WriteLine("Barrier found " + i * _size_x + " " + (i + 1) * _size_x + " " + j * _size_y + " " + (j+1)*_size_y + " " + (i * _size_x >= location.Left) + " " + ((i + 1) * _size_x <= location.Right) + " " + (j * _size_y >= location.Top) + " " + ((j + 1) * _size_y <= location.Bottom));
if (i * _size_x >= location.Left && (i + 1) * _size_x <= location.Right && j * _size_y >= location.Top && (j + 1) * _size_y <= location.Bottom)
{
- Debug.WriteLine("True");
return true;
}
}
diff --git a/Ship/Ship/Direction.cs b/Ship/Ship/Direction.cs
index 4b51bae..56b321d 100644
--- a/Ship/Ship/Direction.cs
+++ b/Ship/Ship/Direction.cs
@@ -9,7 +9,7 @@ namespace Ship
///
/// Направление перемещения
///
- internal enum Direction
+ public enum Direction
{
None = 0,
Up = 1,
diff --git a/Ship/Ship/DrawingShip.cs b/Ship/Ship/DrawingShip.cs
index 40ccd18..07e9db2 100644
--- a/Ship/Ship/DrawingShip.cs
+++ b/Ship/Ship/DrawingShip.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Ship
{
- internal class DrawingShip
+ public class DrawingShip
{
///
/// Класс-сущность
diff --git a/Ship/Ship/EntityShip.cs b/Ship/Ship/EntityShip.cs
index b556451..d3326e7 100644
--- a/Ship/Ship/EntityShip.cs
+++ b/Ship/Ship/EntityShip.cs
@@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace Ship
{
- internal class EntityShip
+ public class EntityShip
{
///
/// Скорость
diff --git a/Ship/Ship/FormMap.Designer.cs b/Ship/Ship/FormMap.Designer.cs
deleted file mode 100644
index 84023d1..0000000
--- a/Ship/Ship/FormMap.Designer.cs
+++ /dev/null
@@ -1,209 +0,0 @@
-namespace Ship
-{
- 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.pictureBoxShip = 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.toolStripStatusLabelColor = 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.buttonDown = new System.Windows.Forms.Button();
- this.buttonRight = new System.Windows.Forms.Button();
- this.buttonCreateModif = new System.Windows.Forms.Button();
- this.comboBoxSelectorMap = new System.Windows.Forms.ComboBox();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
- this.statusStrip.SuspendLayout();
- this.SuspendLayout();
- //
- // pictureBoxShip
- //
- this.pictureBoxShip.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pictureBoxShip.Location = new System.Drawing.Point(0, 0);
- this.pictureBoxShip.Name = "pictureBoxShip";
- this.pictureBoxShip.Size = new System.Drawing.Size(800, 428);
- this.pictureBoxShip.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
- this.pictureBoxShip.TabIndex = 0;
- this.pictureBoxShip.TabStop = false;
- //
- // statusStrip
- //
- this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.toolStripStatusLabelSpeed,
- this.toolStripStatusLabelWeight,
- this.toolStripStatusLabelColor});
- this.statusStrip.Location = new System.Drawing.Point(0, 428);
- this.statusStrip.Name = "statusStrip";
- this.statusStrip.Size = new System.Drawing.Size(800, 22);
- this.statusStrip.TabIndex = 1;
- //
- // toolStripStatusLabelSpeed
- //
- this.toolStripStatusLabelSpeed.Name = "toolStripStatusLabelSpeed";
- this.toolStripStatusLabelSpeed.Size = new System.Drawing.Size(62, 17);
- this.toolStripStatusLabelSpeed.Text = "Скорость:";
- //
- // toolStripStatusLabelWeight
- //
- this.toolStripStatusLabelWeight.Name = "toolStripStatusLabelWeight";
- this.toolStripStatusLabelWeight.Size = new System.Drawing.Size(29, 17);
- this.toolStripStatusLabelWeight.Text = "Вес:";
- //
- // toolStripStatusLabelColor
- //
- this.toolStripStatusLabelColor.Name = "toolStripStatusLabelColor";
- this.toolStripStatusLabelColor.Size = new System.Drawing.Size(36, 17);
- this.toolStripStatusLabelColor.Text = "Цвет:";
- //
- // buttonCreate
- //
- this.buttonCreate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.buttonCreate.Location = new System.Drawing.Point(12, 402);
- this.buttonCreate.Name = "buttonCreate";
- this.buttonCreate.Size = new System.Drawing.Size(75, 23);
- this.buttonCreate.TabIndex = 2;
- this.buttonCreate.Text = "Создать";
- this.buttonCreate.UseVisualStyleBackColor = true;
- this.buttonCreate.Click += new System.EventHandler(this.ButtonCreate_Click);
- //
- // buttonUp
- //
- this.buttonUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonUp.BackgroundImage = global::Ship.Properties.Resources.arrowUp;
- this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonUp.Location = new System.Drawing.Point(722, 359);
- this.buttonUp.Name = "buttonUp";
- this.buttonUp.Size = new System.Drawing.Size(30, 30);
- this.buttonUp.TabIndex = 3;
- this.buttonUp.UseVisualStyleBackColor = true;
- this.buttonUp.Click += new System.EventHandler(this.ButtonMove_Click);
- //
- // buttonLeft
- //
- this.buttonLeft.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonLeft.BackgroundImage = global::Ship.Properties.Resources.arrowLeft;
- this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonLeft.Location = new System.Drawing.Point(686, 395);
- 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);
- //
- // buttonDown
- //
- this.buttonDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.buttonDown.BackgroundImage = global::Ship.Properties.Resources.arrowDown;
- this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonDown.Location = new System.Drawing.Point(722, 395);
- this.buttonDown.Name = "buttonDown";
- this.buttonDown.Size = new System.Drawing.Size(30, 30);
- this.buttonDown.TabIndex = 5;
- 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::Ship.Properties.Resources.arrowRight;
- this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
- this.buttonRight.Location = new System.Drawing.Point(758, 395);
- 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);
- //
- // buttonCreateModif
- //
- this.buttonCreateModif.Location = new System.Drawing.Point(93, 402);
- this.buttonCreateModif.Name = "buttonCreateModif";
- this.buttonCreateModif.Size = new System.Drawing.Size(101, 23);
- this.buttonCreateModif.TabIndex = 7;
- this.buttonCreateModif.Text = "Модификация";
- this.buttonCreateModif.UseVisualStyleBackColor = true;
- this.buttonCreateModif.Click += new System.EventHandler(this.ButtonCreateModif_Click);
- //
- // comboBoxSelectorMap
- //
- this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
- this.comboBoxSelectorMap.FormattingEnabled = true;
- this.comboBoxSelectorMap.Items.AddRange(new object[] {
- "Простая карта",
- "Водяная карта"});
- this.comboBoxSelectorMap.Location = new System.Drawing.Point(12, 12);
- this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
- this.comboBoxSelectorMap.Size = new System.Drawing.Size(121, 23);
- this.comboBoxSelectorMap.TabIndex = 8;
- this.comboBoxSelectorMap.SelectedIndexChanged += new System.EventHandler(this.ComboBoxSelectorMap_SelectedIndexChanged);
- //
- // FormMap
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.comboBoxSelectorMap);
- this.Controls.Add(this.buttonCreateModif);
- this.Controls.Add(this.buttonDown);
- this.Controls.Add(this.buttonRight);
- this.Controls.Add(this.buttonLeft);
- this.Controls.Add(this.buttonUp);
- this.Controls.Add(this.buttonCreate);
- this.Controls.Add(this.pictureBoxShip);
- this.Controls.Add(this.statusStrip);
- this.Name = "FormMap";
- this.Text = "Карта";
- this.Load += new System.EventHandler(this.FormMap_Load);
- ((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).EndInit();
- this.statusStrip.ResumeLayout(false);
- this.statusStrip.PerformLayout();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
-
- #endregion
-
- private PictureBox pictureBoxShip;
- private StatusStrip statusStrip;
- private ToolStripStatusLabel toolStripStatusLabelSpeed;
- private ToolStripStatusLabel toolStripStatusLabelWeight;
- private ToolStripStatusLabel toolStripStatusLabelColor;
- private Button buttonCreate;
- private Button buttonUp;
- private Button buttonLeft;
- private Button buttonDown;
- private Button buttonRight;
- private Button buttonCreateModif;
- private ComboBox comboBoxSelectorMap;
- }
-}
\ No newline at end of file
diff --git a/Ship/Ship/FormMap.cs b/Ship/Ship/FormMap.cs
deleted file mode 100644
index 034dc49..0000000
--- a/Ship/Ship/FormMap.cs
+++ /dev/null
@@ -1,108 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Diagnostics;
-using System.Drawing;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-
-namespace Ship
-{
- public partial class FormMap : Form
- {
- private AbstractMap _abstractMap;
-
- public FormMap()
- {
- InitializeComponent();
- _abstractMap = new SimpleMap();
- }
- ///
- /// Заполнение информации по объекту
- ///
- ///
- private void SetData(DrawingShip ship)
- {
- toolStripStatusLabelSpeed.Text = $"Скорость: {ship.Ship.Speed}";
- toolStripStatusLabelWeight.Text = $"Вес: {ship.Ship.Weight}";
- toolStripStatusLabelColor.Text = $"Цвет: {ship.Ship.BodyColor.Name}";
- pictureBoxShip.Image = _abstractMap.CreateMap(pictureBoxShip.Width, pictureBoxShip.Height, new DrawingObject(ship));
- }
- ///
- /// Обработка нажатия кнопки "Создать"
- ///
- ///
- ///
- private void ButtonCreate_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var ship = new DrawingShip(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
- SetData(ship);
- }
- ///
- /// Изменение размеров формы
- ///
- ///
- ///
- 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;
- }
- pictureBoxShip.Image = _abstractMap?.MoveObject(dir);
- }
- ///
- /// Обработка нажатия кнопки "Модификация"
- ///
- ///
- ///
- private void ButtonCreateModif_Click(object sender, EventArgs e)
- {
- Random rnd = new();
- var ship = new DrawingMotorShip(rnd.Next(100, 300), rnd.Next(1000, 2000),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
- Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
- SetData(ship);
- }
- ///
- /// Смена карты
- ///
- ///
- ///
- private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (comboBoxSelectorMap.Text)
- {
- case "Простая карта":
- _abstractMap = new SimpleMap();
- break;
- case "Водяная карта":
- _abstractMap = new WaterMap();
- break;
- }
- }
- private void FormMap_Load(object sender, EventArgs e)
- {
-
- }
- }
-}
diff --git a/Ship/Ship/FormMapWithSetShips.Designer.cs b/Ship/Ship/FormMapWithSetShips.Designer.cs
new file mode 100644
index 0000000..d9b2337
--- /dev/null
+++ b/Ship/Ship/FormMapWithSetShips.Designer.cs
@@ -0,0 +1,217 @@
+namespace Ship
+{
+ partial class FormMapWithSetShips
+ {
+ ///
+ /// 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.buttonRight = new System.Windows.Forms.Button();
+ this.buttonDown = 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.buttonShowStorage = new System.Windows.Forms.Button();
+ this.buttonRemoveShip = new System.Windows.Forms.Button();
+ this.maskedTextBoxPosition = new System.Windows.Forms.MaskedTextBox();
+ this.buttonAddShip = 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.buttonRight);
+ this.groupBoxTools.Controls.Add(this.buttonDown);
+ this.groupBoxTools.Controls.Add(this.buttonLeft);
+ this.groupBoxTools.Controls.Add(this.buttonUp);
+ this.groupBoxTools.Controls.Add(this.buttonShowOnMap);
+ this.groupBoxTools.Controls.Add(this.buttonShowStorage);
+ this.groupBoxTools.Controls.Add(this.buttonRemoveShip);
+ this.groupBoxTools.Controls.Add(this.maskedTextBoxPosition);
+ this.groupBoxTools.Controls.Add(this.buttonAddShip);
+ this.groupBoxTools.Controls.Add(this.comboBoxSelectorMap);
+ this.groupBoxTools.Dock = System.Windows.Forms.DockStyle.Right;
+ this.groupBoxTools.Location = new System.Drawing.Point(600, 0);
+ this.groupBoxTools.Name = "groupBoxTools";
+ this.groupBoxTools.Size = new System.Drawing.Size(200, 450);
+ this.groupBoxTools.TabIndex = 0;
+ this.groupBoxTools.TabStop = false;
+ this.groupBoxTools.Text = "Инструменты";
+ //
+ // buttonRight
+ //
+ this.buttonRight.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.buttonRight.BackgroundImage = global::Ship.Properties.Resources.arrowRight;
+ this.buttonRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonRight.Location = new System.Drawing.Point(124, 408);
+ this.buttonRight.Name = "buttonRight";
+ this.buttonRight.Size = new System.Drawing.Size(30, 30);
+ this.buttonRight.TabIndex = 10;
+ 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::Ship.Properties.Resources.arrowDown;
+ this.buttonDown.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonDown.Location = new System.Drawing.Point(88, 408);
+ this.buttonDown.Name = "buttonDown";
+ this.buttonDown.Size = new System.Drawing.Size(30, 30);
+ this.buttonDown.TabIndex = 9;
+ 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::Ship.Properties.Resources.arrowLeft;
+ this.buttonLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonLeft.Location = new System.Drawing.Point(52, 408);
+ this.buttonLeft.Name = "buttonLeft";
+ this.buttonLeft.Size = new System.Drawing.Size(30, 30);
+ 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::Ship.Properties.Resources.arrowUp;
+ this.buttonUp.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
+ this.buttonUp.Location = new System.Drawing.Point(88, 372);
+ this.buttonUp.Name = "buttonUp";
+ this.buttonUp.Size = new System.Drawing.Size(30, 30);
+ 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, 315);
+ this.buttonShowOnMap.Name = "buttonShowOnMap";
+ this.buttonShowOnMap.Size = new System.Drawing.Size(169, 37);
+ 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(19, 240);
+ this.buttonShowStorage.Name = "buttonShowStorage";
+ this.buttonShowStorage.Size = new System.Drawing.Size(169, 37);
+ this.buttonShowStorage.TabIndex = 4;
+ this.buttonShowStorage.Text = "Посмотреть хранилище";
+ this.buttonShowStorage.UseVisualStyleBackColor = true;
+ this.buttonShowStorage.Click += new System.EventHandler(this.ButtonShowStorage_Click);
+ //
+ // buttonRemoveShip
+ //
+ this.buttonRemoveShip.Location = new System.Drawing.Point(19, 166);
+ this.buttonRemoveShip.Name = "buttonRemoveShip";
+ this.buttonRemoveShip.Size = new System.Drawing.Size(169, 37);
+ this.buttonRemoveShip.TabIndex = 3;
+ this.buttonRemoveShip.Text = "Удалить корабль";
+ this.buttonRemoveShip.UseVisualStyleBackColor = true;
+ this.buttonRemoveShip.Click += new System.EventHandler(this.ButtonRemoveShip_Click);
+ //
+ // maskedTextBoxPosition
+ //
+ this.maskedTextBoxPosition.Location = new System.Drawing.Point(19, 137);
+ this.maskedTextBoxPosition.Mask = "00";
+ this.maskedTextBoxPosition.Name = "maskedTextBoxPosition";
+ this.maskedTextBoxPosition.Size = new System.Drawing.Size(169, 23);
+ this.maskedTextBoxPosition.TabIndex = 2;
+ //
+ // buttonAddShip
+ //
+ this.buttonAddShip.Location = new System.Drawing.Point(19, 94);
+ this.buttonAddShip.Name = "buttonAddShip";
+ this.buttonAddShip.Size = new System.Drawing.Size(169, 37);
+ this.buttonAddShip.TabIndex = 1;
+ this.buttonAddShip.Text = "Добавить корабль";
+ this.buttonAddShip.UseVisualStyleBackColor = true;
+ this.buttonAddShip.Click += new System.EventHandler(this.ButtonAddShip_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, 22);
+ this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
+ this.comboBoxSelectorMap.Size = new System.Drawing.Size(169, 23);
+ 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(600, 450);
+ this.pictureBox.TabIndex = 1;
+ this.pictureBox.TabStop = false;
+ //
+ // FormMapWithSetShips
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.pictureBox);
+ this.Controls.Add(this.groupBoxTools);
+ this.Name = "FormMapWithSetShips";
+ this.Text = "FormMapWithSetShips";
+ this.Load += new System.EventHandler(this.FormMapWithSetShips_Load);
+ this.groupBoxTools.ResumeLayout(false);
+ this.groupBoxTools.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private GroupBox groupBoxTools;
+ private Button buttonShowOnMap;
+ private Button buttonShowStorage;
+ private Button buttonRemoveShip;
+ private MaskedTextBox maskedTextBoxPosition;
+ private Button buttonAddShip;
+ private ComboBox comboBoxSelectorMap;
+ private PictureBox pictureBox;
+ private Button buttonRight;
+ private Button buttonDown;
+ private Button buttonLeft;
+ private Button buttonUp;
+ }
+}
\ No newline at end of file
diff --git a/Ship/Ship/FormMapWithSetShips.cs b/Ship/Ship/FormMapWithSetShips.cs
new file mode 100644
index 0000000..fe0a3d8
--- /dev/null
+++ b/Ship/Ship/FormMapWithSetShips.cs
@@ -0,0 +1,169 @@
+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 Ship
+{
+ public partial class FormMapWithSetShips : Form
+ {
+ ///
+ /// Объект от класса карты с набором объектов
+ ///
+ private MapWithSetShipsGeneric _mapShipsCollectionGeneric;
+ ///
+ /// Конструктор
+ ///
+ public FormMapWithSetShips()
+ {
+ InitializeComponent();
+ }
+ ///
+ /// Выбор карты
+ ///
+ ///
+ ///
+ private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ AbstractMap map = null;
+ switch (comboBoxSelectorMap.Text)
+ {
+ case "Простая карта":
+ map = new SimpleMap();
+ break;
+ case "Водная карта":
+ map = new WaterMap();
+ break;
+ }
+ if (map != null)
+ {
+ _mapShipsCollectionGeneric = new
+ MapWithSetShipsGeneric(pictureBox.Width, pictureBox.Height, map);
+ }
+ else
+ {
+ _mapShipsCollectionGeneric = null;
+ }
+ }
+ ///
+ /// Добавление объекта
+ ///
+ ///
+ ///
+ private void ButtonAddShip_Click(object sender, EventArgs e)
+ {
+ if (_mapShipsCollectionGeneric == null)
+ {
+ return;
+ }
+ FormShip form = new();
+ if (form.ShowDialog() == DialogResult.OK)
+ {
+ DrawingObject car = new(form.SelectedShip);
+ if (_mapShipsCollectionGeneric + car != -1)
+ {
+ MessageBox.Show("Объект добавлен");
+ pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось добавить объект");
+ }
+ }
+ }
+ ///
+ /// Удаление объекта
+ ///
+ ///
+ ///
+ private void ButtonRemoveShip_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 (_mapShipsCollectionGeneric - pos != null)
+ {
+ MessageBox.Show("Объект удален");
+ pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
+ }
+ else
+ {
+ MessageBox.Show("Не удалось удалить объект");
+ }
+ }
+ ///
+ /// Вывод набора
+ ///
+ ///
+ ///
+ private void ButtonShowStorage_Click(object sender, EventArgs e)
+ {
+ if (_mapShipsCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapShipsCollectionGeneric.ShowSet();
+ }
+ ///
+ /// Вывод карты
+ ///
+ ///
+ ///
+ private void ButtonShowOnMap_Click(object sender, EventArgs e)
+ {
+ if (_mapShipsCollectionGeneric == null)
+ {
+ return;
+ }
+ pictureBox.Image = _mapShipsCollectionGeneric.ShowOnMap();
+ }
+ ///
+ /// Перемещение
+ ///
+ ///
+ ///
+ private void ButtonMove_Click(object sender, EventArgs e)
+ {
+ if (_mapShipsCollectionGeneric == 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 = _mapShipsCollectionGeneric.MoveObject(dir);
+ }
+ private void FormMapWithSetShips_Load(object sender, EventArgs e)
+ {
+
+ }
+ }
+}
diff --git a/Ship/Ship/FormMap.resx b/Ship/Ship/FormMapWithSetShips.resx
similarity index 93%
rename from Ship/Ship/FormMap.resx
rename to Ship/Ship/FormMapWithSetShips.resx
index 2c0949d..f298a7b 100644
--- a/Ship/Ship/FormMap.resx
+++ b/Ship/Ship/FormMapWithSetShips.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/Ship/Ship/FormShip.Designer.cs b/Ship/Ship/FormShip.Designer.cs
index 3e16931..678cf1e 100644
--- a/Ship/Ship/FormShip.Designer.cs
+++ b/Ship/Ship/FormShip.Designer.cs
@@ -39,6 +39,7 @@
this.buttonDown = new System.Windows.Forms.Button();
this.buttonRight = new System.Windows.Forms.Button();
this.buttonCreateModif = new System.Windows.Forms.Button();
+ this.buttonSelectShip = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).BeginInit();
this.statusStrip.SuspendLayout();
this.SuspendLayout();
@@ -152,11 +153,22 @@
this.buttonCreateModif.UseVisualStyleBackColor = true;
this.buttonCreateModif.Click += new System.EventHandler(this.buttonCreateModif_Click);
//
+ // buttonSelectShip
+ //
+ this.buttonSelectShip.Location = new System.Drawing.Point(605, 402);
+ this.buttonSelectShip.Name = "buttonSelectShip";
+ this.buttonSelectShip.Size = new System.Drawing.Size(75, 23);
+ this.buttonSelectShip.TabIndex = 8;
+ this.buttonSelectShip.Text = "Выбрать";
+ this.buttonSelectShip.UseVisualStyleBackColor = true;
+ this.buttonSelectShip.Click += new System.EventHandler(this.buttonSelectShip_Click);
+ //
// FormShip
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
+ this.Controls.Add(this.buttonSelectShip);
this.Controls.Add(this.buttonCreateModif);
this.Controls.Add(this.buttonRight);
this.Controls.Add(this.buttonDown);
@@ -167,6 +179,7 @@
this.Controls.Add(this.statusStrip);
this.Name = "FormShip";
this.Text = "Корабль";
+ this.Load += new System.EventHandler(this.FormShip_Load);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxShip)).EndInit();
this.statusStrip.ResumeLayout(false);
this.statusStrip.PerformLayout();
@@ -188,5 +201,6 @@
private Button buttonDown;
private Button buttonRight;
private Button buttonCreateModif;
+ private Button buttonSelectShip;
}
}
\ No newline at end of file
diff --git a/Ship/Ship/FormShip.cs b/Ship/Ship/FormShip.cs
index f846cc3..74fc689 100644
--- a/Ship/Ship/FormShip.cs
+++ b/Ship/Ship/FormShip.cs
@@ -4,6 +4,8 @@ namespace Ship
{
private DrawingShip _ship;
+ public DrawingShip SelectedShip { get; private set; }
+
public FormShip()
{
InitializeComponent();
@@ -35,7 +37,13 @@ namespace Ship
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new();
- _ship = new DrawingShip(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;
+ }
+ _ship = new DrawingShip(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
_ship.SetPosition(rnd.Next(10, 100), pictureBoxShip.Height - rnd.Next(50, 100),
pictureBoxShip.Width, pictureBoxShip.Height);
SetData();
@@ -86,13 +94,32 @@ namespace Ship
private void buttonCreateModif_Click(object sender, EventArgs e)
{
Random rnd = new();
- _ship = new DrawingMotorShip(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)));
+ Color colorMain = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ Color colorAdd = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
+ ColorDialog dialog = new();
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ colorMain = dialog.Color;
+ }
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ colorAdd = dialog.Color;
+ }
+ _ship = new DrawingMotorShip(rnd.Next(100, 300), rnd.Next(1000, 2000), colorMain, colorAdd, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
_ship.SetPosition(rnd.Next(50, 100), pictureBoxShip.Height - rnd.Next(80, 100), pictureBoxShip.Width, pictureBoxShip.Height);
SetData();
Draw();
}
+
+ private void FormShip_Load(object sender, EventArgs e)
+ {
+
+ }
+
+ private void buttonSelectShip_Click(object sender, EventArgs e)
+ {
+ SelectedShip = _ship;
+ DialogResult = DialogResult.OK;
+ }
}
}
\ No newline at end of file
diff --git a/Ship/Ship/MapWithSetShipsGeneric.cs b/Ship/Ship/MapWithSetShipsGeneric.cs
new file mode 100644
index 0000000..9bf0e93
--- /dev/null
+++ b/Ship/Ship/MapWithSetShipsGeneric.cs
@@ -0,0 +1,188 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ship
+{
+ internal class MapWithSetShipsGeneric
+ where T : class, IDrawingObject
+ where U : AbstractMap
+ {
+ ///
+ /// Ширина окна отрисовки
+ ///
+ private readonly int _pictureWidth;
+ ///
+ /// Высота окна отрисовки
+ ///
+ private readonly int _pictureHeight;
+ ///
+ /// Размер занимаемого объектом места (ширина)
+ ///
+ private readonly int _placeSizeWidth = 210;
+ ///
+ /// Размер занимаемого объектом места (высота)
+ ///
+ private readonly int _placeSizeHeight = 90;
+ ///
+ /// Набор объектов
+ ///
+ private readonly SetShipsGeneric _setShips;
+ ///
+ /// Карта
+ ///
+ private readonly U _map;
+ ///
+ /// Конструктор
+ ///
+ ///
+ ///
+ ///
+ public MapWithSetShipsGeneric(int picWidth, int picHeight, U map)
+ {
+ int width = picWidth / _placeSizeWidth;
+ int height = picHeight / _placeSizeHeight;
+ _setShips = new SetShipsGeneric(width * height);
+ _pictureWidth = picWidth;
+ _pictureHeight = picHeight;
+ _map = map;
+ }
+ ///
+ /// Перегрузка оператора сложения
+ ///
+ ///
+ ///
+ ///
+ public static int operator +(MapWithSetShipsGeneric map, T car)
+ {
+ return map._setShips.Insert(car);
+ }
+ ///
+ /// Перегрузка оператора вычитания
+ ///
+ ///
+ ///
+ ///
+ public static T operator -(MapWithSetShipsGeneric map, int
+ position)
+ {
+ return map._setShips.Remove(position);
+ }
+ ///
+ /// Вывод всего набора объектов
+ ///
+ ///
+ public Bitmap ShowSet()
+ {
+ Shaking();
+ Bitmap bmp = new(_pictureWidth, _pictureHeight);
+ Graphics gr = Graphics.FromImage(bmp);
+ DrawBackground(gr);
+ DrawShips(gr);
+ return bmp;
+ }
+ ///
+ /// Просмотр объекта на карте
+ ///
+ ///
+ public Bitmap ShowOnMap()
+ {
+ Shaking();
+ for (int i = 0; i < _setShips.Count; i++)
+ {
+ var car = _setShips.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 = _setShips.Count - 1;
+ for (int i = 0; i < _setShips.Count; i++)
+ {
+ if (_setShips.Get(i) == null)
+ {
+ for (; j > i; j--)
+ {
+ var car = _setShips.Get(j);
+ if (car != null)
+ {
+ _setShips.Insert(car, i);
+ _setShips.Remove(j);
+ break;
+ }
+ }
+ if (j <= i)
+ {
+ return;
+ }
+ }
+ }
+ }
+ ///
+ /// Метод отрисовки фона
+ ///
+ ///
+ private void DrawBackground(Graphics g)
+ {
+ Pen pen = new(Color.Black, 3);
+ Brush seaBrush = new SolidBrush(Color.Blue);
+ Pen thickPen = new Pen(Color.Black, 8);
+ Pen thinPen = new Pen(Color.Black, 4);
+ 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.FillRectangle(seaBrush, i * _placeSizeWidth, j * _placeSizeHeight + _placeSizeHeight * 3 / 4 - 5, _placeSizeWidth / 2, _placeSizeHeight / 3);
+ g.DrawLine(thickPen, i * _placeSizeWidth, j * _placeSizeHeight - 45, i * _placeSizeWidth + _placeSizeWidth / 2 - 50, j * _placeSizeHeight - 45);
+ g.DrawLine(thinPen, i * _placeSizeWidth + 10, j * _placeSizeHeight - 45, i * _placeSizeWidth + 10, j * _placeSizeHeight - 60);
+ g.DrawLine(thinPen, i * _placeSizeWidth + 20, j * _placeSizeHeight - 45, i * _placeSizeWidth + 20, j * _placeSizeHeight - 60);
+ g.DrawLine(thinPen, i * _placeSizeWidth + 30, j * _placeSizeHeight - 45, i * _placeSizeWidth + 30, j * _placeSizeHeight - 60);
+ g.DrawLine(thinPen, i * _placeSizeWidth + 40, j * _placeSizeHeight - 45, i * _placeSizeWidth + 40, j * _placeSizeHeight - 60);
+ }
+ g.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight);
+ }
+ }
+ ///
+ /// Метод прорисовки объектов
+ ///
+ ///
+ private void DrawShips(Graphics g)
+ {
+ int width = _pictureWidth / _placeSizeWidth;
+ int height = _pictureHeight / _placeSizeHeight;
+
+ for (int i = 0; i < _setShips.Count; i++)
+ {
+ var ship = _setShips.Get(i);
+ if (ship != null)
+ {
+ ship.SetObject((width - i % width - 1) * _placeSizeWidth + 10, (i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
+ ship.DrawningObject(g);
+ }
+ }
+ }
+ }
+}
diff --git a/Ship/Ship/Program.cs b/Ship/Ship/Program.cs
index 85afd21..f783bbe 100644
--- a/Ship/Ship/Program.cs
+++ b/Ship/Ship/Program.cs
@@ -11,7 +11,7 @@ namespace Ship
// 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 FormMapWithSetShips());
}
}
}
\ No newline at end of file
diff --git a/Ship/Ship/SetShipsGeneric.cs b/Ship/Ship/SetShipsGeneric.cs
new file mode 100644
index 0000000..e924df8
--- /dev/null
+++ b/Ship/Ship/SetShipsGeneric.cs
@@ -0,0 +1,111 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Ship
+{
+ internal class SetShipsGeneric
+ where T: class
+ {
+ ///
+ /// Массив объектов, которые храним
+ ///
+ private readonly T[] _places;
+ ///
+ /// Количество объектов в массиве
+ ///
+ public int Count => _places.Length;
+ ///
+ /// Конструктор
+ ///
+ ///
+ public SetShipsGeneric(int count)
+ {
+ _places = new T[count];
+ }
+ ///
+ /// Добавление объекта в набор
+ ///
+ /// Добавляемый корабль
+ ///
+ public int Insert(T ship)
+ {
+ return Insert(ship, 0);
+ }
+ ///
+ /// Добавление объекта в набор на конкретную позицию
+ ///
+ /// Добавляемый корабль
+ /// Позиция
+ ///
+ public int Insert(T ship, int position)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return -1;
+ }
+
+ if (_places[position] == null)
+ {
+ _places[position] = ship;
+ return position;
+ }
+
+ int firstNull = -1;
+
+ for (int i = position + 1; i < Count; i++)
+ {
+ if (_places[i] == null)
+ {
+ firstNull = i;
+ break;
+ }
+ }
+
+ if (firstNull == -1)
+ {
+ return -1;
+ }
+
+ for (int i = firstNull; i > position; i--)
+ {
+ (_places[i], _places[i - 1]) = (_places[i - 1], _places[i]);
+ }
+ _places[position] = ship;
+ return position;
+ }
+ ///
+ /// Удаление объекта из набора с конкретной позиции
+ ///
+ ///
+ ///
+ public T Remove(int position)
+ {
+ if (position < 0 || position >= Count || _places[position] == null)
+ {
+ return null;
+ }
+
+ var result = _places[position];
+
+ _places[position] = null;
+ return result;
+ }
+ ///
+ /// Получение объекта из набора по позиции
+ ///
+ ///
+ ///
+ public T Get(int position)
+ {
+ if (position < 0 || position >= Count)
+ {
+ return null;
+ }
+ return _places[position];
+ }
+
+ }
+}
diff --git a/Ship/Ship/WaterMap.cs b/Ship/Ship/WaterMap.cs
index 59f21f6..e8627e8 100644
--- a/Ship/Ship/WaterMap.cs
+++ b/Ship/Ship/WaterMap.cs
@@ -33,8 +33,8 @@ namespace Ship
}
while (counter < 10)
{
- int x = _random.Next(2, 49);
- int y = _random.Next(3, 50);
+ int x = _random.Next(2, 48);
+ int y = _random.Next(3, 48);
var points = new int[] { _map[x, y], _map[x, y + 1], _map[x - 1, y + 1], _map[x + 1, y + 1] };
var forComparison = new int[] { _freeRoad, _freeRoad, _freeRoad, _freeRoad };
if (points.SequenceEqual(forComparison))