Добавление родителей и ввод конструкторов
This commit is contained in:
parent
f870c99a0b
commit
4a92a4e41c
@ -1,5 +1,4 @@
|
|||||||
|
namespace AntiAircraftGun.Drawnings;
|
||||||
namespace AntiAircraftGun;
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Направление перемещения
|
/// Направление перемещения
|
||||||
/// </summary>
|
/// </summary>
|
@ -1,56 +1,101 @@
|
|||||||
namespace AntiAircraftGun;
|
using AntiAircraftGun.Entities;
|
||||||
/// <summary>
|
using System;
|
||||||
/// Класс отвечающий за прорисовку и перемещение объекта - сущности
|
using System.Collections.Generic;
|
||||||
/// </summary>
|
using System.Linq;
|
||||||
public class DrawningAntiAircraftGun
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.Drawnings;
|
||||||
|
|
||||||
|
public class DrawningAircraftGun
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс - сущность
|
/// Класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityAntiAircraftGun? EntityAntiAircraftGun { get; set; }
|
public EntityAircraftGun? EntityAircraftGun { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина окна
|
/// Ширина
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _pictureWidth;
|
private int? _pictureWidth;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота окна
|
/// Высота
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _pictureHeight;
|
private int? _pictureHeight;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки зенитной установки
|
/// Левая координата прорисовки зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _startPosX;
|
protected int? _startPosX;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя координата прорисовки зенитной установки
|
/// Верхняя координата прорисовки зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int? _startPosY;
|
protected int? _startPosY;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки зенитной установки
|
/// Ширина прорисовки зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningGunWidth = 130;
|
private readonly int _drawningGunWidth = 129;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки зенитной установки
|
/// Высота прорисовки зенитной установки
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly int _drawningGunHeight = 100;
|
private readonly int _drawningGunHeight = 105;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Инициализация полей объекта-класса зенитной установки
|
/// Координата Х объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
public int? GetPosX => _startPosX;
|
||||||
/// <param name="weight">Вес</param>
|
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <summary>
|
||||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
/// Координата Y объекта
|
||||||
/// <param name="bodyKit">Наличие обвеса</param>
|
/// </summary>
|
||||||
/// <param name="tower">Наличие башни</param>
|
public int? GetPosY => _startPosY;
|
||||||
/// <param name="radar">Наличие радара</param>
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tower, bool radar)
|
/// <summary>
|
||||||
|
/// Ширина объекта
|
||||||
|
/// </summary>
|
||||||
|
public int GetWidth => _drawningGunWidth;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Высота объекта
|
||||||
|
/// </summary>
|
||||||
|
public int GetHeight => _drawningGunHeight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Пустой конструктор
|
||||||
|
/// </summary>
|
||||||
|
private DrawningAircraftGun()
|
||||||
{
|
{
|
||||||
EntityAntiAircraftGun = new EntityAntiAircraftGun();
|
|
||||||
EntityAntiAircraftGun.Init(speed, weight, bodyColor, additionalColor, bodyKit, tower, radar);
|
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
_startPosX = null;
|
_startPosX = null;
|
||||||
_startPosY = null;
|
_startPosY = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
public DrawningAircraftGun(int speed, double weight, Color bodyColor) : this()
|
||||||
|
{
|
||||||
|
EntityAircraftGun = new EntityAircraftGun(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор для наследников
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="drawningGunWidth">Ширина прорисовки зенитной установки</param>
|
||||||
|
/// <param name="drawningGunHeight">Высота прорисовки зенитной установки</param>
|
||||||
|
protected DrawningAircraftGun(int drawningGunWidth, int drawningGunHeight) : this()
|
||||||
|
{
|
||||||
|
_drawningGunWidth = drawningGunWidth;
|
||||||
|
_drawningGunHeight = drawningGunHeight;
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка границ поля
|
/// Установка границ поля
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -133,34 +178,34 @@ public class DrawningAntiAircraftGun
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityAntiAircraftGun == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityAircraftGun == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityAntiAircraftGun.Step > 0)
|
if (_startPosX.Value - EntityAircraftGun.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityAntiAircraftGun.Step;
|
_startPosX -= (int)EntityAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + _drawningGunWidth + EntityAntiAircraftGun.Step < _pictureWidth)
|
if (_startPosX.Value + _drawningGunWidth + EntityAircraftGun.Step < _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)EntityAntiAircraftGun.Step;
|
_startPosX += (int)EntityAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY.Value + _drawningGunHeight + EntityAntiAircraftGun.Step < _pictureHeight)
|
if (_startPosY.Value + _drawningGunHeight + EntityAircraftGun.Step < _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)EntityAntiAircraftGun.Step;
|
_startPosY += (int)EntityAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Up: //вверх
|
case DirectionType.Up: //вверх
|
||||||
if (_startPosY - EntityAntiAircraftGun.Step > 0)
|
if (_startPosY - EntityAircraftGun.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= (int)EntityAntiAircraftGun.Step;
|
_startPosY -= (int)EntityAircraftGun.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -171,22 +216,21 @@ public class DrawningAntiAircraftGun
|
|||||||
/// Прорисовка объекта
|
/// Прорисовка объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityAntiAircraftGun == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityAircraftGun == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pen pen = new(Color.Black);
|
Pen pen = new(Color.Black);
|
||||||
Brush additionalBrush = new SolidBrush(EntityAntiAircraftGun.AdditionalColor);
|
|
||||||
|
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
|
g.DrawEllipse(pen, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
|
||||||
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
|
g.DrawEllipse(pen, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 75, 90, 30);
|
g.DrawRectangle(pen, _startPosX.Value + 25, _startPosY.Value + 75, 90, 30);
|
||||||
|
|
||||||
//границы ЦВЕТ
|
//границы ЦВЕТ
|
||||||
Brush brDarkSlateGray = new SolidBrush(EntityAntiAircraftGun.BodyColor);
|
Brush brDarkSlateGray = new SolidBrush(EntityAircraftGun.BodyColor);
|
||||||
g.FillRectangle(brDarkSlateGray, _startPosX.Value + 35, _startPosY.Value + 40, 35, 30);
|
g.FillRectangle(brDarkSlateGray, _startPosX.Value + 35, _startPosY.Value + 40, 35, 30);
|
||||||
g.FillEllipse(brDarkSlateGray, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
|
g.FillEllipse(brDarkSlateGray, _startPosX.Value + 10, _startPosY.Value + 75, 30, 30);
|
||||||
g.FillEllipse(brDarkSlateGray, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
|
g.FillEllipse(brDarkSlateGray, _startPosX.Value + 100, _startPosY.Value + 75, 30, 30);
|
||||||
@ -220,25 +264,7 @@ public class DrawningAntiAircraftGun
|
|||||||
|
|
||||||
g.FillRectangle(brDarkSlateGray, _startPosX.Value + 10, _startPosY.Value + 65, 120, 13);
|
g.FillRectangle(brDarkSlateGray, _startPosX.Value + 10, _startPosY.Value + 65, 120, 13);
|
||||||
|
|
||||||
if (EntityAntiAircraftGun.Tower)
|
|
||||||
{
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 90, _startPosY.Value + 20);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 50, _startPosX.Value + 95, _startPosY.Value + 27);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 60, _startPosY.Value + 50);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 100, _startPosY.Value + 20);
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (EntityAntiAircraftGun.Radar)
|
|
||||||
{
|
|
||||||
g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 65, _startPosX.Value + 20, _startPosY.Value + 40);
|
|
||||||
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
|
|
||||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
64
AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs
Normal file
64
AntiAircraftGun/Drawnings/DrawningAntiAircraftGun.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using AntiAircraftGun.Entities;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.Drawnings;
|
||||||
|
/// <summary>
|
||||||
|
/// Класс отвечающий за прорисовку и перемещение объекта - сущности
|
||||||
|
/// </summary>
|
||||||
|
public class DrawningAntiAircraftGun : DrawningAircraftGun
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed">Скорость</param>
|
||||||
|
/// <param name="weight">Вес</param>
|
||||||
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
|
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||||
|
/// <param name="bodyKit">Признак наличия обвесов</param>
|
||||||
|
/// <param name="tower">Признак наличия башни</param>
|
||||||
|
/// <param name="radar">Признак наличия радара</param>
|
||||||
|
|
||||||
|
public DrawningAntiAircraftGun(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool radar, bool tower) : base(129, 60)
|
||||||
|
{
|
||||||
|
EntityAircraftGun = new EntityAntiAircraftGun(speed, weight, bodyColor, radar, tower, bodyKit, additionalColor);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Прорисовка объекта
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityAircraftGun == null || EntityAircraftGun is not EntityAntiAircraftGun aircraftGun || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush additionalBrush = new SolidBrush(aircraftGun.AdditionalColor);
|
||||||
|
|
||||||
|
base.DrawTransport(g);
|
||||||
|
|
||||||
|
|
||||||
|
if (aircraftGun.Tower)
|
||||||
|
{
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 50, 35, 15);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 90, _startPosY.Value + 20);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 60, _startPosY.Value + 50, _startPosX.Value + 95, _startPosY.Value + 27);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 45, _startPosY.Value + 50, _startPosX.Value + 60, _startPosY.Value + 50);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 90, _startPosY.Value + 20, _startPosX.Value + 100, _startPosY.Value + 20);
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 100, _startPosY.Value + 20, _startPosX.Value + 95, _startPosY.Value + 27);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (aircraftGun.Radar)
|
||||||
|
{
|
||||||
|
g.DrawLine(pen, _startPosX.Value + 20, _startPosY.Value + 65, _startPosX.Value + 20, _startPosY.Value + 40);
|
||||||
|
g.FillRectangle(additionalBrush, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
|
||||||
|
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
40
AntiAircraftGun/Entities/EntityAircraftGun.cs
Normal file
40
AntiAircraftGun/Entities/EntityAircraftGun.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun.Entities;
|
||||||
|
|
||||||
|
public class EntityAircraftGun
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Скорость
|
||||||
|
/// </summary>
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Вес
|
||||||
|
/// </summary>
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Основной цвет
|
||||||
|
/// </summary>
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Перемещение зенитной установки
|
||||||
|
/// </summary>
|
||||||
|
public double Step => Speed * 100 / Weight;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Конструктор сущности
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="speed"></param>
|
||||||
|
/// <param name="weight"></param>
|
||||||
|
/// <param name="bodyColor"></param>
|
||||||
|
public EntityAircraftGun(int speed, double weight, Color bodyColor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
}
|
||||||
|
}
|
@ -1,20 +1,9 @@
|
|||||||
namespace AntiAircraftGun;
|
namespace AntiAircraftGun.Entities;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность Зенитная установка
|
/// Класс-сущность Зенитная установка
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityAntiAircraftGun
|
public class EntityAntiAircraftGun : EntityAircraftGun
|
||||||
{ /// <summary>
|
{
|
||||||
/// Скорость
|
|
||||||
/// </summary>
|
|
||||||
public int Speed { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Вес
|
|
||||||
/// </summary>
|
|
||||||
public double Weight { get; private set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Основной цвет
|
|
||||||
/// </summary>
|
|
||||||
public Color BodyColor { get; private set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дополниетльный цвет
|
/// Дополниетльный цвет
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -31,12 +20,9 @@ public class EntityAntiAircraftGun
|
|||||||
/// Наличие радара
|
/// Наличие радара
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Radar { get; private set; }
|
public bool Radar { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Шаг перемещения гидросамолета
|
/// Инициализация полей объекта-класса зенитной установки
|
||||||
/// </summary>
|
|
||||||
public double Step => Speed * 100 / Weight;
|
|
||||||
/// <summary>
|
|
||||||
/// Инициализация полей объекта-класса гидросамолета
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес</param>
|
/// <param name="weight">Вес</param>
|
||||||
@ -45,14 +31,12 @@ public class EntityAntiAircraftGun
|
|||||||
/// <param name="bodyKit">Наличие обвеса</param>
|
/// <param name="bodyKit">Наличие обвеса</param>
|
||||||
/// <param name="tower">Наличие башни</param>
|
/// <param name="tower">Наличие башни</param>
|
||||||
/// <param name="radar">Наличие радара</param>
|
/// <param name="radar">Наличие радара</param>
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool bodyKit, bool tower, bool radar)
|
public EntityAntiAircraftGun(int speed, double weight, Color bodyColor, bool radar, bool tower, bool bodyKit, Color additionalColor) : base(speed, weight, bodyColor)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
BodyKit = bodyKit;
|
|
||||||
Tower = tower;
|
|
||||||
Radar = radar;
|
Radar = radar;
|
||||||
|
Tower = tower;
|
||||||
|
BodyKit = bodyKit;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
40
AntiAircraftGun/FormAntiAircraftGun.Designer.cs
generated
40
AntiAircraftGun/FormAntiAircraftGun.Designer.cs
generated
@ -29,11 +29,12 @@
|
|||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
pictureBoxAntiAircraftGun = new PictureBox();
|
pictureBoxAntiAircraftGun = new PictureBox();
|
||||||
buttonCreate = new Button();
|
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
buttonUp = new Button();
|
buttonUp = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
buttonCreatAircraftGun = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxAntiAircraftGun).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxAntiAircraftGun).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -46,17 +47,6 @@
|
|||||||
pictureBoxAntiAircraftGun.TabIndex = 0;
|
pictureBoxAntiAircraftGun.TabIndex = 0;
|
||||||
pictureBoxAntiAircraftGun.TabStop = false;
|
pictureBoxAntiAircraftGun.TabStop = false;
|
||||||
//
|
//
|
||||||
// buttonCreate
|
|
||||||
//
|
|
||||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
|
||||||
buttonCreate.Location = new Point(12, 406);
|
|
||||||
buttonCreate.Name = "buttonCreate";
|
|
||||||
buttonCreate.Size = new Size(95, 32);
|
|
||||||
buttonCreate.TabIndex = 1;
|
|
||||||
buttonCreate.Text = "Создать";
|
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
|
||||||
//
|
|
||||||
// buttonLeft
|
// buttonLeft
|
||||||
//
|
//
|
||||||
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
@ -105,11 +95,34 @@
|
|||||||
buttonUp.UseVisualStyleBackColor = true;
|
buttonUp.UseVisualStyleBackColor = true;
|
||||||
buttonUp.Click += ButtonMove_Click;
|
buttonUp.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.Location = new Point(12, 406);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(215, 32);
|
||||||
|
buttonCreate.TabIndex = 1;
|
||||||
|
buttonCreate.Text = "Создать зенитную установку";
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// buttonCreatAircraftGun
|
||||||
|
//
|
||||||
|
buttonCreatAircraftGun.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreatAircraftGun.Location = new Point(233, 406);
|
||||||
|
buttonCreatAircraftGun.Name = "buttonCreatAircraftGun";
|
||||||
|
buttonCreatAircraftGun.Size = new Size(215, 32);
|
||||||
|
buttonCreatAircraftGun.TabIndex = 6;
|
||||||
|
buttonCreatAircraftGun.Text = "Создать установку";
|
||||||
|
buttonCreatAircraftGun.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreatAircraftGun.Click += buttonCreatAircraftGun_Click;
|
||||||
|
//
|
||||||
// FormAntiAircraftGun
|
// FormAntiAircraftGun
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(buttonCreatAircraftGun);
|
||||||
Controls.Add(buttonUp);
|
Controls.Add(buttonUp);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
@ -125,10 +138,11 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private PictureBox pictureBoxAntiAircraftGun;
|
private PictureBox pictureBoxAntiAircraftGun;
|
||||||
private Button buttonCreate;
|
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonUp;
|
private Button buttonUp;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private Button buttonCreatAircraftGun;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,13 @@
|
|||||||
namespace AntiAircraftGun
|
using AntiAircraftGun.Drawnings;
|
||||||
|
|
||||||
|
namespace AntiAircraftGun
|
||||||
{
|
{
|
||||||
public partial class FormAntiAircraftGun : Form
|
public partial class FormAntiAircraftGun : Form
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поле объект для прорисовки объекта
|
/// Поле объект для прорисовки объекта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DrawningAntiAircraftGun? _drawningAntiAircraftGun;
|
private DrawningAircraftGun? _drawningAircraftGun;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// конструктор формы
|
/// конструктор формы
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -18,32 +20,51 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
if (_drawningAntiAircraftGun == null)
|
if (_drawningAircraftGun == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bitmap bmp = new(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
Bitmap bmp = new(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
_drawningAntiAircraftGun.DrawTransport(gr);
|
_drawningAircraftGun.DrawTransport(gr);
|
||||||
pictureBoxAntiAircraftGun.Image = bmp;
|
pictureBoxAntiAircraftGun.Image = bmp;
|
||||||
}
|
}
|
||||||
|
private void CreateObject(string type)
|
||||||
|
{
|
||||||
|
Random random = new();
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case nameof(DrawningAircraftGun):
|
||||||
|
_drawningAircraftGun = new DrawningAircraftGun(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||||
|
break;
|
||||||
|
case nameof(DrawningAntiAircraftGun):
|
||||||
|
_drawningAircraftGun = new DrawningAntiAircraftGun(random.Next(100, 300), random.Next(1000, 3000),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||||
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_drawningAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
||||||
|
_drawningAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
|
Draw();
|
||||||
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка кнопик Создать
|
/// Обработка кнопик Создать Зенитную установку
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAntiAircraftGun));
|
||||||
{
|
/// <summary>
|
||||||
Random random = new();
|
/// Обработка кнопик Создать установку
|
||||||
_drawningAntiAircraftGun = new DrawningAntiAircraftGun();
|
/// </summary>
|
||||||
_drawningAntiAircraftGun.Init(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 255),
|
/// <param name="sender"></param>
|
||||||
random.Next(0, 255), random.Next(0, 255)), Color.FromArgb(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)),
|
/// <param name="e"></param>
|
||||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
private void buttonCreatAircraftGun_Click(object sender, EventArgs e) => CreateObject(nameof(DrawningAircraftGun));
|
||||||
_drawningAntiAircraftGun.SetPictureSize(pictureBoxAntiAircraftGun.Width, pictureBoxAntiAircraftGun.Height);
|
|
||||||
_drawningAntiAircraftGun.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
|
||||||
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Перемещение объекта по форме
|
/// Перемещение объекта по форме
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -51,7 +72,7 @@
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningAntiAircraftGun == null)
|
if (_drawningAircraftGun == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,16 +81,16 @@
|
|||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
result = _drawningAntiAircraftGun.MoveTransport(DirectionType.Up);
|
result = _drawningAircraftGun.MoveTransport(DirectionType.Up);
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
result = _drawningAntiAircraftGun.MoveTransport(DirectionType.Down);
|
result = _drawningAircraftGun.MoveTransport(DirectionType.Down);
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
result = _drawningAntiAircraftGun.MoveTransport(DirectionType.Right);
|
result = _drawningAircraftGun.MoveTransport(DirectionType.Right);
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
result = _drawningAntiAircraftGun.MoveTransport(DirectionType.Left);
|
result = _drawningAircraftGun.MoveTransport(DirectionType.Left);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
@ -77,5 +98,7 @@
|
|||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user