PIbd-21 Kryukov A.I Lab 1 Base #8
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace lab_1_pojectExcavator
|
||||
namespace lab_1_pojectExcavator
|
||||
{
|
||||
public enum DirectionType
|
||||
{
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace lab_1_pojectExcavator
|
||||
namespace lab_1_pojectExcavator
|
||||
{
|
||||
internal class DrawingExcavator
|
||||
{
|
||||
@ -49,13 +43,13 @@ namespace lab_1_pojectExcavator
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool bodyKit, bool backet,int width, int height)
|
||||
additionalColor, bool bodyKit, bool backet, int width, int height)
|
||||
{
|
||||
// TODO: Продумать проверки
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityExcavator = new EntityExcavator();
|
||||
EntityExcavator.Init(speed, weight, bodyColor, additionalColor,bodyKit, backet);
|
||||
EntityExcavator.Init(speed, weight, bodyColor, additionalColor, bodyKit, backet);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@ -68,7 +62,7 @@ namespace lab_1_pojectExcavator
|
||||
// TODO: Изменение x, y
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
|
||||
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
@ -99,14 +93,14 @@ namespace lab_1_pojectExcavator
|
||||
break;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if(_startPosX + EntityExcavator.Step < _pictureWidth - _excavatorWidth)
|
||||
if (_startPosX + EntityExcavator.Step < _pictureWidth - _excavatorWidth)
|
||||
{
|
||||
_startPosX += (int)EntityExcavator.Step;
|
||||
}
|
||||
break;
|
||||
//вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight)
|
||||
if (_startPosY + EntityExcavator.Step < _pictureHeight - _excavatorHeight)
|
||||
{
|
||||
_startPosY += (int)EntityExcavator.Step;
|
||||
}
|
||||
@ -119,12 +113,12 @@ namespace lab_1_pojectExcavator
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
{
|
||||
if(EntityExcavator == null)
|
||||
if (EntityExcavator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pen pen = new(Color.Black);
|
||||
|
||||
|
||||
Brush additionalBrush = new SolidBrush(EntityExcavator.AdditionalColor);
|
||||
if (EntityExcavator.BodyKit)
|
||||
{
|
||||
@ -140,17 +134,17 @@ namespace lab_1_pojectExcavator
|
||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 70, 30, 40);
|
||||
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 90, 10, 20);
|
||||
//гусеница
|
||||
Point[] points = {
|
||||
Point[] points = {
|
||||
new Point(_startPosX + 20, _startPosY + 130),
|
||||
new Point(_startPosX + 15, _startPosY+ 135),
|
||||
new Point(_startPosX + 15, _startPosY+ 135),
|
||||
new Point(_startPosX + 15, _startPosY + 145),
|
||||
new Point(_startPosX + 20, _startPosY + 150),
|
||||
new Point(_startPosX + 145, _startPosY + 150),
|
||||
new Point(_startPosX + 150, _startPosY + 145),
|
||||
new Point(_startPosX + 150, _startPosY + 135),
|
||||
new Point(_startPosX + 145, _startPosY + 130)};
|
||||
g.DrawPolygon(pen,points);
|
||||
g.DrawEllipse(pen,_startPosX + 20,_startPosY + 130, 20,20);
|
||||
g.DrawPolygon(pen, points);
|
||||
g.DrawEllipse(pen, _startPosX + 20, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 40, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 60, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 80, _startPosY + 130, 20, 20);
|
||||
@ -159,8 +153,8 @@ namespace lab_1_pojectExcavator
|
||||
//ковш
|
||||
if (EntityExcavator.Backet)
|
||||
{
|
||||
Point[] pointsBacket = {
|
||||
new Point(_startPosX + 150, _startPosY + 75),
|
||||
Point[] pointsBacket = {
|
||||
new Point(_startPosX + 150, _startPosY + 75),
|
||||
new Point(_startPosX + 150, _startPosY + 135),
|
||||
new Point(_startPosX + 195, _startPosY + 135),
|
||||
};
|
||||
|
@ -1,10 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace lab_1_pojectExcavator
|
||||
namespace lab_1_pojectExcavator
|
||||
{
|
||||
internal class EntityExcavator
|
||||
{
|
||||
@ -32,7 +26,7 @@ namespace lab_1_pojectExcavator
|
||||
/// Признак (опция) наличия ковша
|
||||
/// </summary>
|
||||
public bool Backet { get; private set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// </summary>
|
||||
@ -46,7 +40,7 @@ namespace lab_1_pojectExcavator
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="backet">Признак наличия антикрыла</param>
|
||||
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool bodyKit, bool backet)
|
||||
{
|
||||
|
@ -47,11 +47,11 @@ namespace lab_1_pojectExcavator
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(0, 2)),
|
||||
Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureBoxExcavator.Width,
|
||||
Convert.ToBoolean(random.Next(0, 2)),
|
||||
pictureBoxExcavator.Width,
|
||||
pictureBoxExcavator.Height);
|
||||
_drawnigExcavator.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
_drawnigExcavator.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
private void buttonMove_Click(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user