lab2
This commit is contained in:
parent
a1ae8210cf
commit
18c3e57349
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper
|
||||
namespace Stormtrooper.Drawnings
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
125
Stormtrooper/Stormtrooper/Drawnings/DrawningAircraft.cs
Normal file
125
Stormtrooper/Stormtrooper/Drawnings/DrawningAircraft.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using Stormtrooper.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper.Drawnings;
|
||||
|
||||
public class DrawningAircraft
|
||||
{
|
||||
// Класс-сущность
|
||||
public EntityAircraft? EntityAircraft { get; private set; } // объявление 1
|
||||
|
||||
// Ширина окна
|
||||
|
||||
public int? _pictureWidth;
|
||||
|
||||
// Высота окна
|
||||
|
||||
public int? _pictureHeight;
|
||||
|
||||
// Левая координата прорисовки штурмовика
|
||||
|
||||
protected int? _startPosX;
|
||||
|
||||
// Верхняя координата прорисовки автомобиля
|
||||
|
||||
protected int? _startPosY;
|
||||
|
||||
// Ширина прорисовки штурмовика
|
||||
|
||||
private readonly int _drawningAircraftWidth = 120;
|
||||
|
||||
// Высота прорисовки штурмовика
|
||||
|
||||
private readonly int _drawningAircraftHeight = 140;
|
||||
|
||||
// Пустой конструктор
|
||||
private DrawningAircraft()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
// Конструктор
|
||||
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
public DrawningAircraft(int speed, double weight, Color bodyColor) : this()
|
||||
{
|
||||
EntityAircraft = new EntityAircraft(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
// Конструктор для наследников
|
||||
|
||||
/// <param name="drawningAircraftWidth">Ширина прорисовки штурмовика</param>
|
||||
/// <param name="drawningAircraftHeight">Высота прорисовки штурмовика</param>
|
||||
protected DrawningAircraft(int drawningAircraftWidth, int drawningAircraftHeight) : this()
|
||||
{
|
||||
_drawningAircraftWidth = drawningAircraftWidth;
|
||||
_pictureHeight = drawningAircraftHeight;
|
||||
}
|
||||
|
||||
/// Прорисовка объекта
|
||||
/// <param name="g"></param>
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityAircraft == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyColorBrush = new SolidBrush(EntityAircraft.BodyColor);
|
||||
|
||||
//нос штурмовика
|
||||
Brush brBlack = new SolidBrush(Color.Black);
|
||||
|
||||
Point[] Nose = new Point[3];
|
||||
Nose[0].X = _startPosX.Value + 10; Nose[0].Y = _startPosY.Value + 70;
|
||||
Nose[1].X = _startPosX.Value + 10; Nose[1].Y = _startPosY.Value + 50;
|
||||
Nose[2].X = _startPosX.Value - 10; Nose[2].Y = _startPosY.Value + 60;
|
||||
g.FillPolygon(brBlack, Nose);
|
||||
g.DrawPolygon(pen, Nose);
|
||||
//Заднии крылья штурмовика
|
||||
|
||||
Point[] pflybtwings = new Point[6];
|
||||
pflybtwings[0].X = _startPosX.Value + 110; pflybtwings[0].Y = _startPosY.Value + 50;
|
||||
pflybtwings[1].X = _startPosX.Value + 110; pflybtwings[1].Y = _startPosY.Value + 40;
|
||||
pflybtwings[2].X = _startPosX.Value + 130; pflybtwings[2].Y = _startPosY.Value + 20;
|
||||
pflybtwings[3].X = _startPosX.Value + 130; pflybtwings[3].Y = _startPosY.Value + 100;
|
||||
pflybtwings[4].X = _startPosX.Value + 110; pflybtwings[4].Y = _startPosY.Value + 80;
|
||||
pflybtwings[5].X = _startPosX.Value + 110; pflybtwings[5].Y = _startPosY.Value + 70;
|
||||
g.FillPolygon(bodyColorBrush, pflybtwings);
|
||||
g.DrawPolygon(pen, pflybtwings);
|
||||
//Тело штурмовика
|
||||
g.FillRectangle(bodyColorBrush, _startPosX.Value + 10, _startPosY.Value + 50, 120, 20);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 10, _startPosY.Value + 50, 120, 20);
|
||||
|
||||
|
||||
//Крылья штурмовика
|
||||
|
||||
|
||||
Point[] frontwings = new Point[4];
|
||||
frontwings[0].X = _startPosX.Value + 50; frontwings[0].Y = _startPosY.Value + 50;
|
||||
frontwings[1].X = _startPosX.Value + 50; frontwings[1].Y = _startPosY.Value - 10;
|
||||
frontwings[2].X = _startPosX.Value + 60; frontwings[2].Y = _startPosY.Value - 10;
|
||||
frontwings[3].X = _startPosX.Value + 70; frontwings[3].Y = _startPosY.Value + 50;
|
||||
g.FillPolygon(bodyColorBrush, frontwings);
|
||||
g.DrawPolygon(pen, frontwings);
|
||||
|
||||
Point[] frontwings2 = new Point[4];
|
||||
frontwings2[0].X = _startPosX.Value + 50; frontwings2[0].Y = _startPosY.Value + 70;
|
||||
frontwings2[1].X = _startPosX.Value + 50; frontwings2[1].Y = _startPosY.Value + 130;
|
||||
frontwings2[2].X = _startPosX.Value + 60; frontwings2[2].Y = _startPosY.Value + 130;
|
||||
frontwings2[3].X = _startPosX.Value + 70; frontwings2[3].Y = _startPosY.Value + 70;
|
||||
g.FillPolygon(bodyColorBrush, frontwings2);
|
||||
g.DrawPolygon(pen, frontwings2);
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -7,12 +7,11 @@ using System.Reflection.Metadata;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Stormtrooper.Entities;
|
||||
|
||||
namespace Stormtrooper;
|
||||
public class DrawningStormtrooper
|
||||
namespace Stormtrooper.Drawnings;
|
||||
public class DrawningStormtrooper : DrawningAircraft
|
||||
{
|
||||
// Класс-сущность
|
||||
public EntityStormtrooper? EntityStormtrooper { get; private set; } // объявление
|
||||
|
||||
// Ширина окна
|
||||
|
||||
@ -47,15 +46,12 @@ public class DrawningStormtrooper
|
||||
/// <param name="rocket">Признак наличия ракет</param>
|
||||
/// <param name="bomb">Признак наличия бомбы</param>
|
||||
/// <param name="wing">Признак наличия крыла</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
public DrawningStormtrooper(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool rocket, bool bomb, bool wing)
|
||||
{
|
||||
EntityStormtrooper = new EntityStormtrooper(); // инициализация
|
||||
EntityStormtrooper = new EntityStormtrooper();
|
||||
EntityStormtrooper.Init(speed, weight, bodyColor, additionalColor, rocket, bomb, wing);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
|
||||
}
|
||||
// Установка границ поля
|
||||
|
34
Stormtrooper/Stormtrooper/Entities/EntityAircraft.cs
Normal file
34
Stormtrooper/Stormtrooper/Entities/EntityAircraft.cs
Normal file
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper.Entities;
|
||||
|
||||
// Класс-сущность "самолет"
|
||||
public class EntityAircraft
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
// скорость
|
||||
public double Weight { get; private set; }
|
||||
// вес
|
||||
public Color BodyColor { get; private set; }
|
||||
// цвет
|
||||
public double Step => Speed * 100 / Weight;
|
||||
// шаг в поле
|
||||
/// Конструктор сущности
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес штурмовика</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
|
||||
public EntityAircraft(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
|
||||
}
|
||||
}
|
47
Stormtrooper/Stormtrooper/Entities/EntityStormtrooper.cs
Normal file
47
Stormtrooper/Stormtrooper/Entities/EntityStormtrooper.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper.Entities;
|
||||
|
||||
public class EntityStormtrooper : EntityAircraft
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
// скорость
|
||||
public double Weight { get; private set; }
|
||||
// вес
|
||||
public Color BodyColor { get; private set; }
|
||||
// цвет
|
||||
public Color AdditionalColor { get; private set; }
|
||||
// дополнительные цвета
|
||||
public bool Rocket { get; private set; }
|
||||
// ракета
|
||||
public bool Bomb { get; private set; }
|
||||
// бомба
|
||||
public bool Wing { get; private set; }
|
||||
// крыло
|
||||
|
||||
/// Инициализация полей объекта-класса штурмовика
|
||||
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес штурмовика</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="rocket">Признак наличия ракет</param>
|
||||
/// <param name="bomb">Признак наличия бомб</param>
|
||||
/// <param name="wing">Признак наличия крыла а</param>
|
||||
|
||||
public EntityStormtrooper(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool rocket, bool bomb, bool wing) : base(speed, weight, bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Rocket = rocket;
|
||||
Bomb = bomb;
|
||||
Wing = wing;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Stormtrooper
|
||||
{
|
||||
public class EntityStormtrooper
|
||||
{
|
||||
public int Speed { get; private set; }
|
||||
// скорость
|
||||
public double Weight { get; private set; }
|
||||
// вес
|
||||
public Color BodyColor { get; private set; }
|
||||
// цвет
|
||||
public Color AdditionalColor { get; private set; }
|
||||
// дополнительные цвета
|
||||
public bool Rocket { get; private set; }
|
||||
// ракета
|
||||
public bool Bomb { get; private set; }
|
||||
// бомба
|
||||
public bool Wing { get; private set; }
|
||||
// крыло
|
||||
public double Step => Speed * 100 / Weight;
|
||||
// шаг в поле
|
||||
|
||||
/// Инициализация полей объекта-класса штурмовика
|
||||
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес штурмовика</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="rocket">Признак наличия ракет</param>
|
||||
/// <param name="bomb">Признак наличия бомб</param>
|
||||
/// <param name="wing">Признак наличия крыла а</param>
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool rocket, bool bomb, bool wing)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Rocket = rocket;
|
||||
Bomb = bomb;
|
||||
Wing = wing;
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Stormtrooper.Drawnings;
|
||||
|
||||
namespace Stormtrooper
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user