PIbd-13_Ladyagin_P.D. LabWork02 Simple #4
@ -1,5 +1,4 @@
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
namespace ProjectAirplaneWithRadar.Drawnings
|
||||
{
|
||||
/// <summary>
|
||||
/// Направление перемещения
|
@ -0,0 +1,75 @@
|
||||
using ProjectAirplaneWithRadar.Entities;
|
||||
|
||||
namespace ProjectAirplaneWithRadar.Drawnings
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingAirplaneWithRadar : DrawningAirplane
|
||||
{
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="wheels">Шасси</param>
|
||||
/// <param name="radar">Радар</param>
|
||||
public DrawingAirplaneWithRadar(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar) : base(150, 93)
|
||||
{
|
||||
EntityAirplane = new EntityAirplaneWithRadar(speed, weight, bodyColor, additionalColor, wheels, radar);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplane == null || EntityAirplane is not EntityAirplaneWithRadar airplaneWithRadar || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(airplaneWithRadar.AdditionalColor);
|
||||
|
||||
if (airplaneWithRadar.Wheels)
|
||||
{
|
||||
//Задняя стойка
|
||||
g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 80, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 80, 5, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 85, 10, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 85, 10, 10);
|
||||
|
||||
//Передняя стойка
|
||||
g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value + 80, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 80, 5, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 92, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 92, _startPosY.Value + 85, 10, 10);
|
||||
}
|
||||
|
||||
_startPosY += 10;
|
||||
base.DrawTransport(g);
|
||||
_startPosY -= 10;
|
||||
|
||||
|
||||
//Радар
|
||||
if (airplaneWithRadar.Radar)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 40, 10, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 40, 10, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 30, 50, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 30, 50, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,14 +1,15 @@
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
using ProjectAirplaneWithRadar.Entities;
|
||||
|
||||
|
||||
namespace ProjectAirplaneWithRadar.Drawnings
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawingAirplaneWithRadar
|
||||
public class DrawningAirplane
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityAirplaneWithRadar? EntityAirplaneWithRadar { get; private set; }
|
||||
public EntityAirplane? EntityAirplane { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Ширина окна
|
||||
@ -23,43 +24,76 @@
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
protected int? _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
protected int? _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина прорисовки самолета
|
||||
/// </summary>
|
||||
public readonly int PlaneWidth = 150;
|
||||
private readonly int PlaneWidth = 150;
|
||||
|
||||
/// <summary>
|
||||
/// Высота прорисовки самолета
|
||||
/// </summary>
|
||||
public readonly int PlaneHeight = 95;
|
||||
|
||||
private readonly int PlaneHeight = 85;
|
||||
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// Координата X объекта
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="wheels">Шасси</param>
|
||||
/// <param name="radar">Радар</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool wheels, bool radar)
|
||||
public int? GetPosX => _startPosX;
|
||||
|
||||
/// <summary>
|
||||
/// Координата Y объекта
|
||||
/// </summary>
|
||||
public int? GetPosY => _startPosY;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина объекта
|
||||
/// </summary>
|
||||
public int GetWidth => PlaneWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Высота объекта
|
||||
/// </summary>
|
||||
public int GetHeight => PlaneHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
private DrawningAirplane()
|
||||
{
|
||||
EntityAirplaneWithRadar = new EntityAirplaneWithRadar();
|
||||
EntityAirplaneWithRadar.Init(speed, weight, bodyColor, additionalColor, wheels, radar);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public DrawningAirplane(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityAirplane = new EntityAirplane(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="planeWidth">Ширина прорисовки самолета</param>
|
||||
/// <param name="planeHeight">Высота прорисовки самолета</param>
|
||||
protected DrawningAirplane(int planeWidth, int planeHeight) : this()
|
||||
{
|
||||
PlaneWidth = planeWidth;
|
||||
PlaneHeight = planeHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Установка границ поля
|
||||
/// </summary>
|
||||
@ -138,12 +172,12 @@
|
||||
/// <returns>true - перемещене выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityAirplaneWithRadar == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityAirplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int step = (int)EntityAirplaneWithRadar.Step;
|
||||
int step = (int)EntityAirplane.Step;
|
||||
switch (direction)
|
||||
{
|
||||
//влево
|
||||
@ -184,82 +218,51 @@
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAirplaneWithRadar == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityAirplane == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(EntityAirplaneWithRadar.AdditionalColor);
|
||||
|
||||
//Шасси
|
||||
if (EntityAirplaneWithRadar.Wheels)
|
||||
{
|
||||
//Задняя стойка
|
||||
g.DrawRectangle(pen, _startPosX.Value + 30, _startPosY.Value + 80, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 30, _startPosY.Value + 80, 5, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 20, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 20, _startPosY.Value + 85, 10, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 35, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 35, _startPosY.Value + 85, 10, 10);
|
||||
|
||||
//Передняя стойка
|
||||
g.DrawRectangle(pen, _startPosX.Value + 95, _startPosY.Value + 80, 5, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 95, _startPosY.Value + 80, 5, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 92, _startPosY.Value + 85, 10, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 92, _startPosY.Value + 85, 10, 10);
|
||||
}
|
||||
|
||||
//Радар
|
||||
if (EntityAirplaneWithRadar.Radar)
|
||||
{
|
||||
g.DrawRectangle(pen, _startPosX.Value + 70, _startPosY.Value + 40, 10, 10);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value + 70, _startPosY.Value + 40, 10, 10);
|
||||
|
||||
g.DrawEllipse(pen, _startPosX.Value + 50, _startPosY.Value + 30, 50, 10);
|
||||
g.FillEllipse(additionalBrush, _startPosX.Value + 50, _startPosY.Value + 30, 50, 10);
|
||||
}
|
||||
|
||||
//Корпус
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50, 100, 30);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 40, 100, 30);
|
||||
|
||||
//Хвост
|
||||
Point[] points = {
|
||||
new Point(_startPosX.Value + 10, _startPosY.Value + 10),
|
||||
new Point(_startPosX.Value + 10, _startPosY.Value + 50),
|
||||
new Point(_startPosX.Value + 50, _startPosY.Value + 50)
|
||||
new Point(_startPosX.Value + 10, _startPosY.Value),
|
||||
new Point(_startPosX.Value + 10, _startPosY.Value + 40),
|
||||
new Point(_startPosX.Value + 50, _startPosY.Value + 40)
|
||||
};
|
||||
g.DrawPolygon(pen, points);
|
||||
|
||||
//Кабина
|
||||
Point[] points2 = {
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 45),
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 65),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value + 65)
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 35),
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 55),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value + 55)
|
||||
};
|
||||
g.DrawPolygon(pen, points2);
|
||||
Point[] points3 = {
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 65),
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 85),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value + 65)
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 55),
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + 75),
|
||||
new Point(_startPosX.Value + 150, _startPosY.Value + 55)
|
||||
};
|
||||
g.DrawPolygon(pen, points3);
|
||||
|
||||
//Крыло
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 60, 70, 10);
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 30, _startPosY.Value + 60, 70, 10);
|
||||
Brush brBlack = new SolidBrush(EntityAirplane.BodyColor);
|
||||
g.DrawEllipse(pen, _startPosX.Value + 30, _startPosY.Value + 50, 70, 10);
|
||||
g.FillEllipse(brBlack, _startPosX.Value + 30, _startPosY.Value + 50, 70, 10);
|
||||
|
||||
//Хвостовой элерон
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 45, 30, 10);
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 45, 30, 10);
|
||||
g.DrawEllipse(pen, _startPosX.Value, _startPosY.Value + 35, 30, 10);
|
||||
g.FillEllipse(brBlack, _startPosX.Value, _startPosY.Value + 35, 30, 10);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
namespace ProjectAirplaneWithRadar.Entities
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность "Самолет"
|
||||
|
@ -1,4 +1,5 @@
|
||||
using ProjectAirplaneWithRadar.Entities;
|
||||
using ProjectAirplaneWithRadar.Drawnings;
|
||||
using ProjectAirplaneWithRadar.Entities;
|
||||
|
||||
namespace ProjectAirplaneWithRadar
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user