PIbd-21_Putintsev_D.M._Road.../RoadTrain/DrawningTrain.cs

59 lines
2.1 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 RoadTrain.Entities;
using System.Drawing;
namespace RoadTrain.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningTrain : DrawningRoadTrain
{
/// <summary>
/// Конструктор
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Основной цвет</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="waterContainer">Признак наличия обвеса</param>
/// <param name="sweepingBrush">Признак наличия антикрыла</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
public DrawningTrain(int speed, double weight, Color bodyColor, Color
additionalColor, bool waterContainer, bool sweepingBrush, int width, int height) :base(speed, weight, bodyColor, width, height)
{
if (EntityRoadTrain != null)
{
EntityRoadTrain = new EntityTrain(speed, weight, bodyColor,
additionalColor, waterContainer, sweepingBrush);
}
}
public override void DrawTransport(Graphics g)
{
if (EntityRoadTrain is not EntityTrain train)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(train.AdditionalColor);
//Контейнер с водой
if (train.WaterContainer)
{
g.DrawEllipse(pen, _startPosX + 30, _startPosY, 10, 20);
g.FillEllipse(additionalBrush, _startPosX + 30, _startPosY, 10, 20);
}
base.DrawTransport(g);
if (train.SweepingBrush)
{
g.DrawLine(pen, _startPosX + 30, _startPosY + 10, _startPosX + 20, _startPosY + 10);
g.DrawLine(pen, _startPosX + 20, _startPosY + 10, _startPosX + 10, _startPosY + 30);
g.DrawLine(pen, _startPosX + 17, _startPosY + 30, _startPosX + 3, _startPosY + 30);
}
}
public void SetAdditionalColor(Color color)
{
(EntityRoadTrain as EntityTrain).SetAdditionalColor(color);
}
}
}