83 lines
3.2 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.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using ProjectBulldozer.Entities;
namespace ProjectBulldozer.Drawnings;
/// <summary>
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningBulldozer : DrawningDozer
{
private EntityDozer dozer;
/// <summary>
/// Другой конструктор.
/// </summary>
/// <param name="dozer"></param>
public DrawningBulldozer(EntityDozer? entityDozer) : base(150, 90)
{
if (entityDozer != null)
{
EntityDozer = entityDozer;
}
}
///<summary>
///Конструктор
/// </summary>
/// ///<param name="speed">Скорость</param>
///<param name="weight">Вес</param>
///<param name="bodyColor">Основной цвет</param>
///<param name="additionalColor">Дополнительный цвет</param>
///<param name="blade">Признак наличия отвала</param>
///<param name="caterpillar">Признак наличия гусеницы</param>
public DrawningBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar) : base(150, 90)
{
EntityDozer = new EntityBulldozer(speed, weight, bodyColor, additionalColor, blade, caterpillar);
}
public override void DrawTransport(Graphics g)
{
if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue || EntityDozer is not EntityBulldozer bulldozer)
{
return;
}
Pen pen = new(Color.Black);
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
Brush additionalBrush = new SolidBrush(bulldozer.AdditionalColor);
//BULDOZER
_startPosX += 0;
_startPosY += 0;
base.DrawTransport(g);
_startPosX -= 0;
_startPosY -= 0;
//caterpillar
if (bulldozer.Caterpillar)
{
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 150, 15);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 150, 15);
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 75, 150, 15);
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 75, 150, 15);
}
//blade
if (bulldozer.Blade)
{ //smth like hands?
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
//blade itself
g.FillRectangle(bodyBrush, _startPosX.Value + 125, _startPosY.Value, 25, 90);
g.DrawRectangle(pen, _startPosX.Value + 125, _startPosY.Value, 25, 90);
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value + 90);
}
}
}