Проба пера
This commit is contained in:
parent
0584c4874c
commit
e2a51ace3c
@ -6,29 +6,29 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace WarmlyShip
|
namespace WarmlyShip
|
||||||
{
|
{
|
||||||
internal class DrawningWarmlyShip
|
internal class DrawingWarmlyShip
|
||||||
{
|
{
|
||||||
public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность
|
public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность
|
||||||
protected float _startPosX; //Координаты отрисовки по оси x
|
public float _startPosX; //Координаты отрисовки по оси x
|
||||||
protected float _startPosY; //Координаты отрисовки по оси y
|
public float _startPosY; //Координаты отрисовки по оси y
|
||||||
private int? _pictureWidth = null; //Ширина окна
|
private int? _pictureWidth = null; //Ширина окна
|
||||||
private int? _pictureHeight = null; //Высота окна
|
private int? _pictureHeight = null; //Высота окна
|
||||||
protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
|
protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
|
||||||
protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля
|
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);
|
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;
|
_warmlyShipWidth = warmlyWidth;
|
||||||
_warmlyShipHeight = warmlyHeight;
|
_warmlyShipHeight = warmlyHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Начальная позиция коробля
|
//Начальные коордитанты
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
if (width < _warmlyShipWidth || height < _warmlyShipHeight) return;
|
if (width < _warmlyShipWidth || height < _warmlyShipHeight) return;
|
||||||
@ -39,7 +39,7 @@ namespace WarmlyShip
|
|||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Функция передвижения объекта
|
//Движение транспорта по координатам
|
||||||
public void MoveTransport(Direction direction)
|
public void MoveTransport(Direction direction)
|
||||||
{
|
{
|
||||||
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return;
|
if (!_pictureWidth.HasValue || !_pictureHeight.HasValue) return;
|
||||||
@ -73,8 +73,8 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
new Point((int)(_startPosX), (int)(_startPosY + 20)),
|
new Point((int)(_startPosX), (int)(_startPosY + 20)),
|
||||||
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
|
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
|
||||||
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
|
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)),
|
||||||
new Point((int)(_startPosX + 25), (int)(_startPosY +50))
|
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight))
|
||||||
});
|
});
|
||||||
g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
|
g.FillRectangle(brush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
|
||||||
g.FillEllipse(new SolidBrush(Color.Aquamarine), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 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), (int)(_startPosY + 20)),
|
||||||
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
|
new Point((int)(_startPosX + _warmlyShipWidth), (int)(_startPosY + 20)),
|
||||||
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + 50)),
|
new Point((int)(_startPosX + _warmlyShipWidth - 25), (int)(_startPosY + _warmlyShipHeight)),
|
||||||
new Point((int)(_startPosX + 25), (int)(_startPosY + 50))
|
new Point((int)(_startPosX + 25), (int)(_startPosY + _warmlyShipHeight))
|
||||||
});
|
});
|
||||||
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
|
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth * 3 / 5, 20);
|
||||||
g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);
|
g.DrawEllipse(new(Color.Blue, 2), _startPosX + _warmlyShipWidth / 5, _startPosY + 25, 20, 20);
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace WarmlyShip
|
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)
|
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75)
|
||||||
{
|
{
|
||||||
|
@ -8,9 +8,9 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
internal class DrawningObjectShip : IDrawningObject
|
internal class DrawningObjectShip : IDrawningObject
|
||||||
{
|
{
|
||||||
private DrawningWarmlyShip _warmlyShip = null;
|
private DrawingWarmlyShip _warmlyShip = null;
|
||||||
|
|
||||||
public DrawningObjectShip(DrawningWarmlyShip warmlyShip)
|
public DrawningObjectShip(DrawingWarmlyShip warmlyShip)
|
||||||
{
|
{
|
||||||
_warmlyShip = warmlyShip;
|
_warmlyShip = warmlyShip;
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,7 @@ namespace WarmlyShip
|
|||||||
public Color BodyColor { get; private set; } //Цвет
|
public Color BodyColor { get; private set; } //Цвет
|
||||||
public float Step => Speed * 100 / Weight; //Шаг при перемещении
|
public float Step => Speed * 100 / Weight; //Шаг при перемещении
|
||||||
|
|
||||||
|
//Инициализация
|
||||||
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
|
public EntityWarmlyShip(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
@ -2,7 +2,7 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
public partial class FormClass : Form
|
public partial class FormClass : Form
|
||||||
{
|
{
|
||||||
private DrawningWarmlyShip _warmlyShip;
|
private DrawingWarmlyShip _warmlyShip;
|
||||||
|
|
||||||
public FormClass()
|
public FormClass()
|
||||||
{
|
{
|
||||||
@ -29,7 +29,7 @@ namespace WarmlyShip
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
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();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace WarmlyShip
|
|||||||
_abstractMap = new SimpleMap();
|
_abstractMap = new SimpleMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetData(DrawningWarmlyShip warmlyShip)
|
private void SetData(DrawingWarmlyShip warmlyShip)
|
||||||
{
|
{
|
||||||
toolStripStatusSpeed.Text = $"Скорость: {warmlyShip.warmlyShip?.Speed}";
|
toolStripStatusSpeed.Text = $"Скорость: {warmlyShip.warmlyShip?.Speed}";
|
||||||
toolStripStatusWeight.Text = $"Вес: {warmlyShip.warmlyShip?.Weight}";
|
toolStripStatusWeight.Text = $"Вес: {warmlyShip.warmlyShip?.Weight}";
|
||||||
@ -32,7 +32,7 @@ namespace WarmlyShip
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random random = new Random();
|
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);
|
SetData(warmlyShip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user