diff --git a/Battleship/Battleship/DrawningBattleship.cs b/Battleship/Battleship/DrawningBattleship.cs
index b8b3106..1072b10 100644
--- a/Battleship/Battleship/DrawningBattleship.cs
+++ b/Battleship/Battleship/DrawningBattleship.cs
@@ -41,39 +41,40 @@ public class DrawningBattleship
/// Ширина прорисовки корабля
///
- private readonly int _drawningBattleshipWidth = 110;
+ private readonly int _drawningBattleshipWidth = 150;
///
/// Высота прорисовки корабля
///
- private readonly int _drawningBattleshipHeight = 65;
+ private readonly int _drawningBattleshipHeight = 60;
///
- /// Инициализация полей объекта-класса спортивного корабля
+ /// Инициализация корабля
///
/// Скорость
/// Вес автомобиля
/// Основной цвет
/// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия оружия
- /// Признак наличия отсека ракет
+ /// Признак наличия орудийной башни
+ /// Признак наличия отсека под ракеты
+ ///Признак наличия отсека под ракеты
public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyKit, bool weapon, bool rockets)
+ additionalColor, bool turret, bool rocketCompartment, bool weapon)
{
EntityBattleship = new EntityBattleship();
- EntityBattleship.Init(speed, weight, bodyColor, additionalColor, bodyKit, weapon, rockets);
+ EntityBattleship.Init(speed, weight, bodyColor, additionalColor,
+ turret, rocketCompartment, weapon);
_pictureWidth = null;
_pictureHeight = null;
_startPosX = null;
_startPosY = null;
}
- ///
- /// Установка границ поля
- ///
- /// Ширина поля
- /// Высота поля
- /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
- public bool SetPictureSize(int width, int height)
+ ///
+ /// Установка границ поля
+ ///
+ /// Ширина поля
+ /// Высота поля
+ /// true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
+ public bool SetPictureSize(int width, int height)
{
_pictureWidth = width;
_pictureHeight = height;
@@ -158,18 +159,28 @@ public class DrawningBattleship
int y = _startPosY.Value;
// Корпус корабля
- g.FillRectangle(bodyBrush, x + 15, y + 40, 80, 30);
- g.DrawRectangle(pen, x + 15, y + 40, 80, 30);
-
- // Нос корабля (треугольник)
- Point[] nose = {
- new Point(x + 95, y + 40),
- new Point(x + 95, y + 70),
- new Point(x + 110, y + 55)
+ Point[] body = new Point[] {
+ new Point(x + 5, y),
+ new Point(x + 100, y),
+ new Point(x + 150, y + 25),
+ new Point(x + 100, y + 50),
+ new Point(x + 5, y + 50)
};
- g.FillPolygon(bodyBrush, nose);
- g.DrawPolygon(pen, nose);
- // Пушки (реалистичные)
+ g.FillPolygon(bodyBrush, body);
+ g.DrawPolygon(pen, body);
+
+ Brush brBlack = new SolidBrush(Color.Black);
+ g.FillRectangle(brBlack, x, y + 6, 5, 13);
+ g.FillRectangle(brBlack, x, y + 31, 5, 13);
+
+ Brush brDark = new SolidBrush(Color.DarkGray);
+ g.FillRectangle(brDark, x + 39, y + 20, 40, 10);
+ g.DrawRectangle(pen, x + 39, y + 20, 40, 10);
+ g.FillRectangle(brDark, x + 70, y + 12, 18, 26);
+ g.DrawRectangle(pen, x + 70, y + 12, 18, 26);
+ g.FillEllipse(brBlack, x + 94, y + 19, 12, 12);
+
+ // Пушки
if (EntityBattleship.Weapon)
{
g.FillRectangle(additionalBrush, x + 20, y + 35, 8, 20);
@@ -180,19 +191,35 @@ public class DrawningBattleship
g.DrawRectangle(pen, x + 82, y + 35, 8, 20);
g.DrawLine(pen, x + 86, y + 30, x + 86, y + 35);
}
-
- // Ракеты (улучшены)
- if (EntityBattleship.Rockets)
+ // Отсек под ракеты
+ if (EntityBattleship.RocketCompartment)
{
- 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);
+ for (int i = 0; i < 2; i++)
+ {
+ for (int j = 0; j < 2; j++)
+ {
+ int offsetX = 14 + (i * 12);
+ int offsetY = 14 + (j * 12);
+ g.FillRectangle(additionalBrush, x + offsetX, y + offsetY, 10, 10);
+ g.DrawRectangle(pen, x + offsetX, y + offsetY, 10, 10);
+ }
+ }
}
+
+ // Орудийная башня
+ if (EntityBattleship.Turret)
+ {
+ Point[] turret = new Point[] {
+ new Point(x + 112, y + 19),
+ new Point(x + 112, y + 31),
+ new Point(x + 119, y + 28),
+ new Point(x + 119, y + 22)
+ };
+ g.FillPolygon(additionalBrush, turret);
+ g.FillRectangle(additionalBrush, x + 119, y + 24, 12, 2);
+ g.DrawPolygon(pen, turret);
+ g.DrawRectangle(pen, x + 119, y + 24, 12, 2);
+ }
+
}
-
-
}
diff --git a/Battleship/Battleship/EntityBattleship.cs b/Battleship/Battleship/EntityBattleship.cs
index dbbdd4d..338e7ae 100644
--- a/Battleship/Battleship/EntityBattleship.cs
+++ b/Battleship/Battleship/EntityBattleship.cs
@@ -15,46 +15,45 @@
///
public Color BodyColor { get; private set; }
///
- /// Дополнительный цвет (для опциональных элементов)
+ /// Дополнительный цвет
///
public Color AdditionalColor { get; private set; }
///
- /// Признак (опция) наличия обвеса
+ /// Признак наличия орудийной башни
+ ///
+ public bool Turret { get; private set; }
+ ///
+ /// Признак наличия отсека под ракеты
+ ///
+ public bool RocketCompartment { get; private set; }
+ ///
+ /// Шаг перемещения корабля
///
-
public bool Weapon { get; private set; }
///
- /// Признак (опция) наличия гоночной полосы
- ///
-
- public bool Tower { get; private set; }
- ///
- /// Признак (опция) наличия гоночной полосы
- ///
- public bool Rockets { get; private set; }
- ///
- /// Шаг перемещения автомобиля
+ /// Признак наличия оружия
///
public double Step => Speed * 100 / Weight;
///
- /// Инициализация полей объекта-класса спортивного автомобиля
+ /// Инициализация полей объекта-класса корабля
///
/// Скорость
/// Вес автомобиля
/// Основной цвет
/// Дополнительный цвет
- /// Признак наличия обвеса
- /// Признак наличия оружия
- /// Признак наличия отсека ракет
+ /// Признак наличия орудийной башни
+ /// Признак наличия отсека под ракеты
+ ///Признак наличия отсека под ракеты
public void Init(int speed, double weight, Color bodyColor, Color
- additionalColor, bool bodyKit, bool weapon, bool rockets)
+ additionalColor, bool turret, bool rocketCompartment, bool weapon)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
+ Turret = turret;
+ RocketCompartment = rocketCompartment;
Weapon = weapon;
- Rockets = rockets;
}
diff --git a/Battleship/Battleship/Form1.Designer.cs b/Battleship/Battleship/Form1.Designer.cs
new file mode 100644
index 0000000..18ae06a
--- /dev/null
+++ b/Battleship/Battleship/Form1.Designer.cs
@@ -0,0 +1,39 @@
+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
new file mode 100644
index 0000000..1d6c6e1
--- /dev/null
+++ b/Battleship/Battleship/Form1.cs
@@ -0,0 +1,10 @@
+namespace Battleship
+{
+ public partial class Form1 : Form
+ {
+ public Form1()
+ {
+ InitializeComponent();
+ }
+ }
+}
diff --git a/Battleship/Battleship/Form1.resx b/Battleship/Battleship/Form1.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/Battleship/Battleship/Form1.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