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