84 lines
3.0 KiB
C#
84 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
using Sailboat.Entities;
|
|
|
|
namespace Sailboat.DrawingObjects
|
|
{
|
|
public class DrawingSailboat : DrawingBoat
|
|
{
|
|
public DrawingSailboat(int speed, double weight, Color bodyColor, Color additionalColor, bool hull, bool sail, int width, int height) :
|
|
base(speed, weight, bodyColor, width, height, 160, 160)
|
|
{
|
|
if (EntityBoat != null)
|
|
{
|
|
EntityBoat = new EntitySailboat(speed, weight, bodyColor,
|
|
additionalColor, hull, sail);
|
|
}
|
|
}
|
|
public override void DrawTransport(Graphics g)
|
|
{
|
|
if (EntityBoat is not EntitySailboat sailboat)
|
|
{
|
|
return;
|
|
}
|
|
Pen pen = new(Color.Aqua);
|
|
Brush additionalBrush = new
|
|
SolidBrush(sailboat.AdditionalColor);
|
|
|
|
//усиленный корпус парусника
|
|
if (sailboat.Hull)
|
|
{
|
|
Point[] hullCooler = new Point[]
|
|
{
|
|
new Point(_startPosX, _startPosY + 80),
|
|
new Point(_startPosX + 120, _startPosY + 80),
|
|
new Point(_startPosX + 160, _startPosY + 120),
|
|
new Point(_startPosX + 120, _startPosY + 160),
|
|
new Point(_startPosX, _startPosY + 160)
|
|
};
|
|
g.FillPolygon(additionalBrush, hullCooler);
|
|
g.DrawPolygon(pen, hullCooler);
|
|
}
|
|
|
|
base.DrawTransport(g);
|
|
|
|
//парус
|
|
if (sailboat.Sail)
|
|
{
|
|
Brush sailBrush = new
|
|
SolidBrush(sailboat.AdditionalColor);
|
|
|
|
Point[] sail = new Point[]
|
|
{
|
|
new Point(_startPosX + 65, _startPosY),
|
|
new Point(_startPosX + 130, _startPosY + 120),
|
|
new Point(_startPosX + 15, _startPosY + 120)
|
|
};
|
|
g.FillPolygon(sailBrush, sail);
|
|
g.DrawPolygon(pen, sail);
|
|
//Флаг
|
|
Brush addBrush = new
|
|
SolidBrush(Color.Aqua);
|
|
Brush flagBrush = new
|
|
SolidBrush(sailboat.AdditionalColor);
|
|
Point[] flag = new Point[]
|
|
{
|
|
new Point(_startPosX + 65, _startPosY - 15),
|
|
new Point(_startPosX + 65, _startPosY + 10),
|
|
new Point(_startPosX + 20, _startPosY + 10),
|
|
new Point(_startPosX + 20, _startPosY - 15),
|
|
};
|
|
g.FillPolygon(addBrush, flag);
|
|
g.DrawPolygon(pen, flag);
|
|
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 130), new Point(_startPosX + 65, _startPosY - 15));
|
|
g.DrawLine(pen, new Point(_startPosX + 65, _startPosY + 120), new Point(_startPosX + 65, _startPosY));
|
|
}
|
|
}
|
|
}
|
|
}
|