diff --git a/Battleship/Battleship/DrawningBattleship.cs b/Battleship/Battleship/DrawningBattleship.cs index 4dd4f62..1892835 100644 --- a/Battleship/Battleship/DrawningBattleship.cs +++ b/Battleship/Battleship/DrawningBattleship.cs @@ -1,11 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Text; -using System.Threading.Tasks; - -namespace Battleship; +namespace Battleship; /// /// Класс, отвечающий за прорисовку и перемещение объекта-сущности @@ -76,9 +69,13 @@ public class DrawningBattleship /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах public bool SetPictureSize(int width, int height) { - _pictureWidth = width; - _pictureHeight = height; - return true; + if (width >= _drawningBattleshipWidth || height >= _drawningBattleshipHeight) + { + _pictureWidth = width; + _pictureHeight = height; + return true; + } + return false; } /// /// Установка позиции @@ -87,10 +84,26 @@ public class DrawningBattleship /// Координата Y public void SetPosition(int x, int y) { - if (!_pictureHeight.HasValue || !_pictureWidth.HasValue) + if (x < 0) { - return; + x = 0; } + else if (x + _drawningBattleshipWidth > _pictureWidth.Value) + { + x = _pictureWidth.Value - _drawningBattleshipWidth; + } + + if (y < 0) + { + y = 0; + } + else if (y + _drawningBattleshipHeight > _pictureHeight.Value) + { + y = _pictureHeight.Value - _drawningBattleshipHeight; + } + + + _startPosX = x; _startPosY = y; } @@ -175,9 +188,8 @@ public class DrawningBattleship new Point(x + 95, y + 70), new Point(x + 110, y + 55) }; - g.FillPolygon(bodyBrush, nose); - g.DrawPolygon(pen, nose); - // Пушки + + // Пушка Brush brBlack = new SolidBrush(Color.Black); g.FillRectangle(brBlack, x, y + 6, 5, 13); g.FillRectangle(brBlack, x, y + 31, 5, 13); @@ -201,18 +213,8 @@ public class DrawningBattleship g.DrawLine(pen, x + 86, y + 30, x + 86, y + 35); } - // Ракеты - if (EntityBattleship.Rockets) - { - g.FillRectangle(additionalBrush, x + 25, y + 50, 6, 15); - g.DrawRectangle(pen, x + 25, y + 50, 6, 15); - g.FillEllipse(additionalBrush, x + 27, y + 45, 4, 4); - g.FillRectangle(additionalBrush, x + 79, y + 50, 6, 15); - g.DrawRectangle(pen, x + 79, y + 50, 6, 15); - g.FillEllipse(additionalBrush, x + 81, y + 45, 4, 4); - } - } + // Отсек под ракеты if (EntityBattleship.RocketCompartment) { diff --git a/Battleship/Battleship/Form1.Designer.cs b/Battleship/Battleship/Form1.Designer.cs deleted file mode 100644 index 18ae06a..0000000 --- a/Battleship/Battleship/Form1.Designer.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Battleship -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.components = new System.ComponentModel.Container(); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Text = "Form1"; - } - - #endregion - } -} diff --git a/Battleship/Battleship/Form1.cs b/Battleship/Battleship/Form1.cs deleted file mode 100644 index 1d6c6e1..0000000 --- a/Battleship/Battleship/Form1.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Battleship -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - } -} diff --git a/Battleship/Battleship/Form1.resx b/Battleship/Battleship/Form1.resx deleted file mode 100644 index 1af7de1..0000000 --- a/Battleship/Battleship/Form1.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file