Compare commits
2 Commits
0f508fa568
...
7cb730e265
Author | SHA1 | Date | |
---|---|---|---|
7cb730e265 | |||
4d138f7172 |
@ -19,7 +19,7 @@ where T : class, IDrawingObject
|
|||||||
// Размер занимаемого объектом места (высота)
|
// Размер занимаемого объектом места (высота)
|
||||||
private readonly int _placeSizeHeight = 150;
|
private readonly int _placeSizeHeight = 150;
|
||||||
// Набор объектов
|
// Набор объектов
|
||||||
private readonly SetLocomotivGeneric<T> _setLocomotive;
|
private readonly SetLocomotiveGeneric<T> _setLocomotive;
|
||||||
// Карта
|
// Карта
|
||||||
private readonly U _map;
|
private readonly U _map;
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ where T : class, IDrawingObject
|
|||||||
{
|
{
|
||||||
int width = picWidth / _placeSizeWidth;
|
int width = picWidth / _placeSizeWidth;
|
||||||
int height = picHeight / _placeSizeHeight;
|
int height = picHeight / _placeSizeHeight;
|
||||||
_setLocomotive = new SetLocomotivGeneric<T>(width * height);
|
_setLocomotive = new SetLocomotiveGeneric<T>(width * height);
|
||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_map = map;
|
_map = map;
|
||||||
@ -121,30 +121,20 @@ where T : class, IDrawingObject
|
|||||||
// Метод прорисовки объектов
|
// Метод прорисовки объектов
|
||||||
private void DrawLocomotive(Graphics g)
|
private void DrawLocomotive(Graphics g)
|
||||||
{
|
{
|
||||||
int widthEl = _pictureWidth / _placeSizeWidth;
|
int xPosition = _pictureWidth - _placeSizeWidth;
|
||||||
int heightEl = _pictureHeight / _placeSizeHeight;
|
int yPosition = 12;
|
||||||
|
|
||||||
int curWidth = 0;
|
for (int i = 0; i < _setLocomotive.Count; i++)
|
||||||
int curHeight = 0;
|
|
||||||
|
|
||||||
for (int i = _setLocomotive.Count; i >= 0; i--)
|
|
||||||
{
|
{
|
||||||
_setLocomotive.Get(i)?.SetObject(_pictureWidth - _placeSizeWidth * curWidth - 85,
|
_setLocomotive.Get(i)?.SetObject(xPosition, yPosition, _pictureWidth, _pictureHeight);
|
||||||
curHeight * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
|
||||||
_setLocomotive.Get(i)?.DrawingObject(g);
|
_setLocomotive.Get(i)?.DrawingObject(g);
|
||||||
|
|
||||||
if (curWidth < widthEl)
|
xPosition -= _placeSizeWidth;
|
||||||
curWidth++;
|
if (xPosition < 0)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
curWidth = 1;
|
yPosition += _placeSizeHeight;
|
||||||
curHeight++;
|
xPosition = _pictureWidth - _placeSizeWidth;
|
||||||
}
|
}
|
||||||
if (curHeight > heightEl)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace Monorail
|
namespace Monorail
|
||||||
{
|
{
|
||||||
internal class SetLocomotivGeneric<T>
|
internal class SetLocomotiveGeneric<T>
|
||||||
where T : class
|
where T : class
|
||||||
{
|
{
|
||||||
// Массив объектов, которые храним
|
// Массив объектов, которые храним
|
||||||
@ -14,7 +14,7 @@ where T : class
|
|||||||
// Количество объектов в массиве
|
// Количество объектов в массиве
|
||||||
public int Count => _places.Length;
|
public int Count => _places.Length;
|
||||||
// Конструктор
|
// Конструктор
|
||||||
public SetLocomotivGeneric(int count)
|
public SetLocomotiveGeneric(int count)
|
||||||
{
|
{
|
||||||
_places = new T[count];
|
_places = new T[count];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user