using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Excavator { internal class DrawingExc { public EntityExcavator? EntityExcavator { get; private set; } private int _pictureWidth; private int _pictureHeight; private int _startPosX; private int _startPosY; private readonly int _excWidth = 200; private readonly int _excHeight = 124; public bool Init(EntityExcavator bus, int width, int height) { _pictureWidth = width; _pictureHeight = height; EntityExcavator = bus; if (_pictureWidth < _excWidth || _pictureHeight < _excHeight) { return false; } return true; } public void SetPosition(int x, int y) { _startPosX = x; _startPosY = y; if (_startPosX + _excWidth > _pictureWidth) { _startPosX = _pictureWidth - _excWidth; } if (_startPosX < 0) { _startPosX = 0; } if (_startPosY + _excHeight > _pictureHeight) { _startPosY = _pictureHeight - _excHeight; } if (_startPosY < 0) { _startPosY = 0; } } public void MoveTransport(Direction direction) { if (EntityExcavator == null) { return; } switch (direction) { case Direction.Left: if (_startPosX - EntityExcavator.Step > -17) { _startPosX -= (int)EntityExcavator.Step; } break; case Direction.Up: if (_startPosY - EntityExcavator.Step > -35) { _startPosY -= (int)EntityExcavator.Step; } break; case Direction.Right: if (_startPosX + EntityExcavator.Step + _excWidth + 14 < _pictureWidth) { _startPosX += (int)EntityExcavator.Step; } break; case Direction.Down: if (_startPosY + EntityExcavator.Step + _excHeight < _pictureHeight) { _startPosY += (int)EntityExcavator.Step; } break; } } public void DrawTransport(Graphics g) { if (EntityExcavator == null) { return; } Pen pen = new(Color.Black); Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor); g.FillRectangle(additionalBrush, _startPosX + 40, _startPosY + 60, 140, 35); //маленький g.FillRectangle(additionalBrush, _startPosX + 70, _startPosY + 30, 15, 35); //2 g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 30, 40, 40); //большой прямоугольник 2 Brush additionalBrush1 = new SolidBrush(EntityExcavator.AdditionalColor); if (EntityExcavator.bucket) { Brush additionalBrush2 = new SolidBrush(EntityExcavator.AdditionalColor); g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 70, 20, 5); g.FillRectangle(additionalBrush, _startPosX + 10, _startPosY + 65, 15, 50); } if (EntityExcavator.Support) { g.FillRectangle(additionalBrush, _startPosX + 170, _startPosY + 75, 35, 5); g.FillRectangle(additionalBrush, _startPosX + 200, _startPosY + 55, 15, 45); g.FillRectangle(additionalBrush, _startPosX + 195, _startPosY + 100, 30, 5); } Brush gr = new SolidBrush(Color.Gray); g.FillEllipse(additionalBrush1, _startPosX + 30, _startPosY + 100, 25, 25); g.FillEllipse(additionalBrush1, _startPosX + 155, _startPosY + 100, 25, 25); g.FillEllipse(gr, _startPosX + 65, _startPosY + 108, 17, 17); g.FillEllipse(gr, _startPosX + 95, _startPosY + 108, 17, 17); g.FillEllipse(gr, _startPosX + 120, _startPosY + 108, 17, 17); g.FillEllipse(gr, _startPosX + 83, _startPosY + 100, 8, 8); g.FillEllipse(gr, _startPosX + 110, _startPosY + 100, 8, 8); Pen blackPen = new Pen(Color.Black, 3); Rectangle rect1 = new Rectangle(_startPosX + 25, _startPosY + 97, 30, 30); g.DrawArc(blackPen, rect1, 90, 180); Rectangle rect2 = new Rectangle(_startPosX + 155, _startPosY + 97, 30, 30); g.DrawArc(blackPen, rect2, -90, 180); g.DrawLine(blackPen, _startPosX + 37, _startPosY + 97, _startPosX + 175, _startPosY + 97); g.DrawLine(blackPen, _startPosX + 37, _startPosY + 127, _startPosX + 175, _startPosY + 127); } } }