Puk
This commit is contained in:
parent
e392583d50
commit
2bfb286f5d
@ -8,13 +8,13 @@ namespace WarmlyShip
|
|||||||
{
|
{
|
||||||
internal class DrawingWarmlyShip
|
internal class DrawingWarmlyShip
|
||||||
{
|
{
|
||||||
public EntityWarmlyShip warmlyShip { private set; get; } //Класс-сущность
|
public EntityWarmlyShip warmlyShip { protected set; get; } //Класс-сущность
|
||||||
public float _startPosX; //Координаты отрисовки по оси x
|
protected float _startPosX; //Координаты отрисовки по оси x
|
||||||
public float _startPosY; //Координаты отрисовки по оси y
|
protected float _startPosY; //Координаты отрисовки по оси y
|
||||||
private int? _pictureWidth = null; //Ширина окна
|
private int? _pictureWidth = null; //Ширина окна
|
||||||
private int? _pictureHeight = null; //Высота окна
|
private int? _pictureHeight = null; //Высота окна
|
||||||
private readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
|
protected readonly int _warmlyShipWidth = 125; //Ширина отрисовки корабля
|
||||||
private readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля
|
protected readonly int _warmlyShipHeight = 50; //Высота отрисовки корабля
|
||||||
|
|
||||||
//Инициализация
|
//Инициализация
|
||||||
public DrawingWarmlyShip(int speed, float weight, Color bodyColor)
|
public DrawingWarmlyShip(int speed, float weight, Color bodyColor)
|
||||||
@ -22,6 +22,12 @@ namespace WarmlyShip
|
|||||||
warmlyShip = new EntityWarmlyShip(speed, weight, bodyColor);
|
warmlyShip = new EntityWarmlyShip(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)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
@ -55,7 +61,7 @@ namespace WarmlyShip
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Отрисовка транспорта
|
//Отрисовка транспорта
|
||||||
public void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||||
{
|
{
|
||||||
|
44
WarmlyShip/WarmlyShip/DrawningMotorShip.cs
Normal file
44
WarmlyShip/WarmlyShip/DrawningMotorShip.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WarmlyShip
|
||||||
|
{
|
||||||
|
internal class DrawningMotorShip : DrawingWarmlyShip
|
||||||
|
{
|
||||||
|
public DrawningMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor, 150, 75)
|
||||||
|
{
|
||||||
|
warmlyShip = new EntityMotorShip(speed, weight, bodyColor, dopColor, tubes , cistern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (warmlyShip is not EntityMotorShip motorShip)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Pen pen = new(Color.Black, 2);
|
||||||
|
Brush dopBrush = new SolidBrush(motorShip.DopColor);
|
||||||
|
if (motorShip.Tubes)
|
||||||
|
{
|
||||||
|
g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||||
|
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||||
|
g.FillRectangle(dopBrush, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||||
|
g.DrawRectangle(pen, _startPosX + _warmlyShipWidth * 3 / 5, _startPosY, _warmlyShipWidth / 5, _warmlyShipHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
_startPosY += 25;
|
||||||
|
base.DrawTransport(g);
|
||||||
|
_startPosY -= 25;
|
||||||
|
|
||||||
|
if (motorShip.Cistern)
|
||||||
|
{
|
||||||
|
g.FillEllipse(dopBrush, _startPosX, _startPosY + 25, 25, 20);
|
||||||
|
g.DrawEllipse(pen, _startPosX, _startPosY + 25, 25, 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
WarmlyShip/WarmlyShip/EntityMotorShip.cs
Normal file
24
WarmlyShip/WarmlyShip/EntityMotorShip.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WarmlyShip
|
||||||
|
{
|
||||||
|
internal class EntityMotorShip : EntityWarmlyShip
|
||||||
|
{
|
||||||
|
public Color DopColor { get; private set; }
|
||||||
|
public bool Tubes { get; private set; }
|
||||||
|
public bool Cistern { get; private set; }
|
||||||
|
|
||||||
|
public EntityMotorShip(int speed, float weight, Color bodyColor, Color dopColor, bool tubes, bool cistern) : base(speed, weight, bodyColor)
|
||||||
|
{
|
||||||
|
DopColor = dopColor;
|
||||||
|
Tubes = tubes;
|
||||||
|
Cistern = cistern;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user