64 lines
2.3 KiB
C#
64 lines
2.3 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
|
||
namespace Sailboat
|
||
{
|
||
/// <summary>
|
||
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||
/// </summary>
|
||
class DrawingSailboat : DrawingBoat
|
||
{
|
||
/// <summary>
|
||
/// Инициализация свойств
|
||
/// </summary>
|
||
/// <param name="speed">Скорость</param>
|
||
/// <param name="weight">Вес автомобиля</param>
|
||
/// <param name="bodyColor">Цвет кузова</param>
|
||
/// <param name="sail">Признак наличия паруса</param>
|
||
/// <param name="extendedBody">Признак наличия усиленного корпуса</param>
|
||
public DrawingSailboat(int speed, float weight, Color bodyColor, Color edgeColor , bool sail, bool extendedBody) :
|
||
base(speed, weight, bodyColor, 80, 135)
|
||
{
|
||
Boat = new Sailboat(speed, weight, bodyColor, edgeColor, sail, extendedBody);
|
||
}
|
||
public override void DrawTransport(Graphics g)
|
||
{
|
||
if (Boat is not Sailboat sailboat)
|
||
{
|
||
return;
|
||
}
|
||
|
||
Pen pen = new(Color.Black);
|
||
Brush brush = new SolidBrush(sailboat.EdgeColor);
|
||
|
||
_startPosY += 40;
|
||
_startPosX += 20;
|
||
base.DrawTransport(g);
|
||
_startPosY -= 40;
|
||
_startPosX -= 20;
|
||
|
||
if (sailboat.Sail)
|
||
{
|
||
g.DrawLine(pen, _startPosX + 40, _startPosY, _startPosX + 60, _startPosY + 60);
|
||
g.DrawLine(pen, _startPosX + 40, _startPosY, _startPosX + 70, _startPosY + 30);
|
||
g.DrawLine(pen, _startPosX + 70, _startPosY + 30, _startPosX + 60, _startPosY + 55);
|
||
}
|
||
|
||
if (sailboat.ExtendedBody)
|
||
{
|
||
//корма
|
||
g.FillRectangle(brush, _startPosX + 15, _startPosY + 38, 70, 5);
|
||
g.FillRectangle(brush, _startPosX + 15, _startPosY + 78, 70, 5);
|
||
g.FillRectangle(brush, _startPosX + 15, _startPosY + 38, 5, 40);
|
||
//усиленный нос
|
||
g.FillRectangle(brush, _startPosX + 133, _startPosY + 55, 10, 10);
|
||
}
|
||
}
|
||
|
||
}
|
||
}
|