DozorovaA.A_SecondLabWork #2
@ -70,10 +70,10 @@ namespace ArmoredVehicle
|
||||
//влево
|
||||
case Direction.Left:
|
||||
busy = false;
|
||||
i = (int)Math.Ceiling((XTop - _drawningObject.Step )/ _size_x);
|
||||
j = (int)Math.Ceiling(YBottom / _size_y);
|
||||
jt = (int)Math.Ceiling(YTop / _size_y);
|
||||
i1 = (int)Math.Ceiling((XTop)/ _size_x);
|
||||
i = Math.Abs((int)Math.Ceiling((XTop - _drawningObject.Step )/ _size_x));
|
||||
j = Math.Abs((int)Math.Ceiling(YBottom / _size_y));
|
||||
jt = Math.Abs((int)Math.Ceiling(YTop / _size_y));
|
||||
i1 = Math.Abs((int)Math.Ceiling((XTop)/ _size_x));
|
||||
for (int r = i; r < i1; ++r)
|
||||
{
|
||||
for (int b = jt; b < j; ++b)
|
||||
@ -96,10 +96,10 @@ namespace ArmoredVehicle
|
||||
case Direction.Up:
|
||||
{
|
||||
busy = false;
|
||||
i = (int)Math.Ceiling((XTop) / _size_x);
|
||||
j = (int)((YTop)/ _size_y);
|
||||
jt = (int)((YTop - _drawningObject.Step )/ _size_y);
|
||||
i1 = (int)Math.Ceiling(XBottom / _size_x);
|
||||
i = Math.Abs((int)Math.Ceiling((XTop) / _size_x));
|
||||
j = Math.Abs((int)((YTop)/ _size_y));
|
||||
jt = Math.Abs((int)((YTop - _drawningObject.Step )/ _size_y));
|
||||
i1 = Math.Abs((int)Math.Ceiling(XBottom / _size_x));
|
||||
for (int r = i; r < i1; ++r)
|
||||
{
|
||||
for (int b = jt; b < j; ++b)
|
||||
@ -161,10 +161,30 @@ namespace ArmoredVehicle
|
||||
{
|
||||
return false;
|
||||
}
|
||||
(float XTop, float YTop, float XBottom, float YBottom) = _drawningObject.GetCurrentPosition();
|
||||
|
||||
int x = _random.Next(0, 10);
|
||||
int y = _random.Next(0, 10);
|
||||
|
||||
int beginI = (int)(x / _size_x);
|
||||
int endI = (int)(XBottom / _size_x);
|
||||
|
||||
int beginJ = (int)(y / _size_y);
|
||||
int endJ = (int)(YBottom / _size_y);
|
||||
|
||||
for (int i = beginI; i <= endI; i++)
|
||||
{
|
||||
for(int j = beginJ; j <= endJ; j++)
|
||||
{
|
||||
if(_map[i, j] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_drawningObject.SetObject(x, y, _width, _height);
|
||||
// TODO првоерка, что объект не "накладывается" на закрытые участки
|
||||
return true;
|
||||
}
|
||||
private Bitmap DrawMapWithObject()
|
||||
|
@ -161,9 +161,6 @@ namespace ArmoredVehicle
|
||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY+20, 200, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 15, _startPosY + 25, 200, 35);
|
||||
|
||||
|
||||
pen = new(Color.Red);
|
||||
g.DrawRectangle(pen, _startPosX + 15, _startPosY, _ArmoredVehicleWidth, _ArmoredVehicleHeight);
|
||||
}
|
||||
/// <summary>
|
||||
/// Смена границ формы отрисовки
|
||||
|
@ -20,6 +20,7 @@ namespace ArmoredVehicle
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
base.DrawTransport(g);
|
||||
|
||||
Brush br = new SolidBrush(machine?.DopColor ?? Color.Black);
|
||||
@ -37,9 +38,16 @@ namespace ArmoredVehicle
|
||||
g.DrawLine(p, _startPosX + 90, _startPosY - 45, _startPosX + 90, _startPosY - 30);
|
||||
g.DrawLine(p, _startPosX + 85, _startPosY - 35, _startPosX + 120, _startPosY - 35);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX + 15, _startPosY - 45, _startPosX + 250, _startPosY + 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
{
|
||||
private DrawingArmoredVehicle _machine = null;
|
||||
|
||||
public DrawningObject(DrawingArmoredVehicle car)
|
||||
public DrawningObject(DrawingArmoredVehicle machine)
|
||||
{
|
||||
_machine = car;
|
||||
_machine = machine;
|
||||
}
|
||||
|
||||
public float Step => _machine?.ArmoredVehicle?.Step ?? 0;
|
||||
|
Loading…
Reference in New Issue
Block a user