PIbd-21_Valitov_D.F_Sailboa.../Sailboat/DrawingSailboat.cs

121 lines
5.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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, bool sail, bool extendedBody) :
base(speed, weight, bodyColor, 50, 120)
{
Boat = new Sailboat(speed, weight, bodyColor, sail, extendedBody);
}
public override void DrawTransport(Graphics g)
{
if (Boat is not Sailboat sailboat)
{
return;
}
Pen pen = new(Color.Black);
Brush brush = new SolidBrush(Color.Black);
_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);
}
/*
Brush dopBrush = new SolidBrush(sportCar.DopColor);
if (sportCar.BodyKit)
{
g.DrawEllipse(pen, _startPosX + 90, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX + 90, _startPosY + 40, 20, 20);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 10, 20, 40);
g.DrawRectangle(pen, _startPosX + 90, _startPosY, 15, 15);
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 45, 15, 15);
g.FillEllipse(dopBrush, _startPosX + 90, _startPosY, 20, 20);
g.FillEllipse(dopBrush, _startPosX + 90, _startPosY + 40, 20, 20);
g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 10, 20, 40);
g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 1, 15, 15);
g.FillRectangle(dopBrush, _startPosX + 90, _startPosY + 45, 15, 15);
g.DrawEllipse(pen, _startPosX, _startPosY, 20, 20);
g.DrawEllipse(pen, _startPosX, _startPosY + 40, 20, 20);
g.DrawRectangle(pen, _startPosX, _startPosY + 10, 20, 40);
g.DrawRectangle(pen, _startPosX + 5, _startPosY, 14, 15);
g.DrawRectangle(pen, _startPosX + 5, _startPosY + 45, 14, 15);
g.FillEllipse(dopBrush, _startPosX, _startPosY, 20, 20);
g.FillEllipse(dopBrush, _startPosX, _startPosY + 40, 20, 20);
g.FillRectangle(dopBrush, _startPosX + 1, _startPosY + 10, 25, 40);
g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 1, 15, 15);
g.FillRectangle(dopBrush, _startPosX + 5, _startPosY + 45, 15, 15);
g.DrawRectangle(pen, _startPosX + 35, _startPosY, 39, 15);
g.DrawRectangle(pen, _startPosX + 35, _startPosY + 45, 39, 15);
g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 1, 40, 15);
g.FillRectangle(dopBrush, _startPosX + 35, _startPosY + 45, 40, 15);
}
_startPosX += 10;
_startPosY += 5;
base.DrawTransport(g);
_startPosX -= 10;
_startPosY -= 5;
if (sportCar.SportLine)
{
g.FillRectangle(dopBrush, _startPosX + 76, _startPosY + 23, 24, 15);
g.FillRectangle(dopBrush, _startPosX + 36, _startPosY + 23, 34, 15);
g.FillRectangle(dopBrush, _startPosX + 11, _startPosY + 23, 14, 15);
}
if (sportCar.Wing)
{
g.FillRectangle(dopBrush, _startPosX, _startPosY + 5, 10, 50);
g.DrawRectangle(pen, _startPosX, _startPosY + 5, 10, 50);
}
*/
}
}
}