Проба пера

This commit is contained in:
Макс Бондаренко 2022-10-18 19:56:18 +04:00
parent 0584c4874c
commit e2a51ace3c
6 changed files with 21 additions and 20 deletions

View File

@ -6,29 +6,29 @@ using System.Threading.Tasks;
namespace WarmlyShip
{
internal class DrawningWarmlyShip
internal class DrawingWarmlyShip
{
public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность
protected float _startPosX; //Координаты отрисовки по оси x
protected float _startPosY; //Координаты отрисовки по оси y
public float _startPosX; //Координаты отрисовки по оси x
public float _startPosY; //Координаты отрисовки по оси y
private int? _pictureWidth = null; //Ширина окна
private int? _pictureHeight = null; //Высота окна
protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля
//Конструктор класса
public DrawningWarmlyShip(int speed, float weight, Color bodyColor)
//Инициализация
public DrawingWarmlyShip(int speed, float weight, Color bodyColor)
{
warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
}
protected DrawningWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor)
protected DrawingWarmlyShip(int speed, float weight, Color bodyColor, int warmlyWidth, int warmlyHeight) : this(speed, weight, bodyColor)
{
_warmlyShipWidth = warmlyWidth;
_warmlyShipHeight = warmlyHeight;
}
//Начальная позиция коробля
//Начальные коордитанты
public void SetPosition(int x, int y, int width, int height)
{
if (width < _warmlyShipWidth || height < _warmlyShipHeight) return;
@ -39,7 +39,7 @@ namespace WarmlyShip
_pictureHeight = height;
}
//Функция передвижения объекта
//Движение транспорта по координатам
public void MoveTransport(Direction direction)
{
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return;
@ -73,8 +73,8 @@ namespace WarmlyShip
{
new Point((int)(_startPosX), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
new Point((int)(_startPosX + 25), (int)(_startPosY +50))
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)),
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight))
});
g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);
@ -84,8 +84,8 @@ namespace WarmlyShip
{
new Point((int)(_startPosX), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
new Point((int)(_startPosX + 25), (int)(_startPosY + 50))
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)),
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight))
});
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace WarmlyShip
{
internal class DrawningMotorShip : DrawningWarmlyShip
internal class DrawningMotorShip : DrawingWarmlyShip
{
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75)
{

View File

@ -8,9 +8,9 @@ namespace WarmlyShip
{
internal class DrawningObjectShip : IDrawningObject
{
private DrawningWarmlyShip _warmlyShip = null;
private DrawingWarmlyShip _warmlyShip = null;
public DrawningObjectShip(DrawningWarmlyShip warmlyShip)
public DrawningObjectShip(DrawingWarmlyShip warmlyShip)
{
_warmlyShip = warmlyShip;
}

View File

@ -13,6 +13,7 @@ namespace WarmlyShip
public Color BodyColor { get; private set; } //Цвет
public float Step => Speed * 100 / Weight; //Шаг при перемещении
//Инициализация
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
{
Random random = new Random();

View File

@ -2,7 +2,7 @@ namespace WarmlyShip
{
public partial class FormClass : Form
{
private DrawningWarmlyShip _warmlyShip;
private DrawingWarmlyShip _warmlyShip;
public FormClass()
{
@ -29,7 +29,7 @@ namespace WarmlyShip
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_warmlyShip = new DrawningWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
_warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
SetData();
Draw();
}

View File

@ -20,7 +20,7 @@ namespace WarmlyShip
_abstractMap = new SimpleMap();
}
private void SetData(DrawningWarmlyShip warmlyShip)
private void SetData(DrawingWarmlyShip warmlyShip)
{
toolStripStatusSpeed.Text = $"Скорость: {warmlyShip.warmlyShip?.Speed}";
toolStripStatusWeight.Text = $"Вес: {warmlyShip.warmlyShip?.Weight}";
@ -32,7 +32,7 @@ namespace WarmlyShip
private void ButtonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
var warmlyShip = new DrawningWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
var warmlyShip = new DrawingWarmlyShip(random.Next(100, 300), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
SetData(warmlyShip);
}