Lab_3_Kryukov_AI_Excavator

This commit is contained in:
1SooNoo1 2023-10-10 20:54:30 +04:00
parent fddb6dc9e8
commit eb9c542791
5 changed files with 13 additions and 22 deletions

View File

@ -18,7 +18,6 @@ namespace ProjectExcavator.DrawningObjects
/// Получение объекта IMoveableObject из объекта DrawningCar
/// </summary>
public IMoveableObject GetMoveableObject => new DrawningObjectExcavator(this);
/// <summary>
/// Ширина окна
/// </summary>
@ -175,7 +174,7 @@ namespace ProjectExcavator.DrawningObjects
}
Pen pen = new(Color.Black);
//корпус
Brush bodyBrush = new SolidBrush(Color.Aqua);
Brush bodyBrush = new SolidBrush(EntityExcavator.BodyColor);
g.FillRectangle(bodyBrush, _startPosX + 20, _startPosY + 60, 130, 20);
g.FillRectangle(bodyBrush, _startPosX + 100, _startPosY + 20, 30, 40);
g.FillRectangle(bodyBrush, _startPosX + 30, _startPosY + 40, 10, 20);

View File

@ -1,5 +1,6 @@
using ProjectExcavator.DrawningObjects;
using ProjectExcavator.MovementStrategy;
using System.Drawing;
namespace ProjectExcavator
{
@ -51,12 +52,18 @@ namespace ProjectExcavator
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog mainDialog = new ColorDialog();
if (mainDialog.ShowDialog() == DialogResult.OK)
{
color = mainDialog.Color;
}
_drawnigExcavator = new DrawningExcavator(
random.Next(100, 300),
random.Next(1000, 3000),
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
color,
pictureBoxExcavator.Width,
pictureBoxExcavator.Height);
pictureBoxExcavator.Height) ;
Draw();
}
private void buttonMove_Click(object sender, EventArgs e)

View File

@ -15,7 +15,7 @@ namespace ProjectExcavator.Generic
{
private readonly int _pictureWidth;
private readonly int _pictureHeight;
private readonly int _placeSizeWidth = 210;
private readonly int _placeSizeWidth = 200;
private readonly int _placeSizeHeight = 110;
private readonly SetGeneric<T> _collection;
public ExcavatorGenericCollection(int picWidth, int picHeight)
@ -64,7 +64,7 @@ namespace ProjectExcavator.Generic
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++)
{
g.DrawLine(pen, i * i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
g.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
}
g.DrawLine(pen, i * _placeSizeWidth, 0, i *
_placeSizeWidth, _pictureHeight / _placeSizeHeight * _placeSizeHeight);

View File

@ -27,7 +27,7 @@ namespace ProjectExcavator
ExcavatorForm form = new();
if (form.ShowDialog() == DialogResult.OK)
{
if (_excavators + form.SelectedExcavator)
if (_excavators + form.SelectedExcavator != -1)
{
MessageBox.Show("Объект добален");
pictureBoxCollection.Image = _excavators.ShowExcavator();

View File

@ -17,21 +17,6 @@ namespace ProjectExcavator
}
public int Insert(T excavator)
{
int i = 0;
for (; i < _places.Length; i++)
{
if (_places[i] == null)
{
break;
}
}
if (i == _places.Length)
return -1;
for (; i > 0; i--)
{
_places[i] = _places[i - 1];
}
_places[i] = excavator;
return Insert(excavator,0);
}
public int Insert(T excavator, int position)