Правлен PlanesGenericCollection
This commit is contained in:
parent
650b42c43a
commit
d140d781b7
@ -25,7 +25,11 @@ public class PlanesGenericCollection<T extends DrawingPlane, U extends IMoveable
|
||||
}
|
||||
|
||||
public T Sub(int pos) {
|
||||
return _collection.Remove(pos);
|
||||
T obj = _collection.Get(pos);
|
||||
if (obj != null) {
|
||||
_collection.Remove(pos);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
public U GetU(int pos) {
|
||||
@ -55,18 +59,19 @@ public class PlanesGenericCollection<T extends DrawingPlane, U extends IMoveable
|
||||
private void DrawObjects(Graphics g) {
|
||||
int placesColumnCount = _pictureHeight / _placeSizeHeight;
|
||||
int placesRowCount = _pictureWidth / _placeSizeWidth;
|
||||
for (int i = 0; i < _collection.Count(); i++) {
|
||||
// получение объекта
|
||||
var obj = _collection.Get(i);
|
||||
int i = 0;
|
||||
for (var obj :
|
||||
_collection.GetEnumerator()) {
|
||||
// установка позиции
|
||||
if (obj == null)
|
||||
continue;
|
||||
obj.SetPosition(
|
||||
(placesRowCount - 1) * _placeSizeWidth - (i % placesColumnCount * _placeSizeWidth) + (_placeSizeWidth - obj.GetWidth()) / 2,
|
||||
i / placesColumnCount * _placeSizeHeight + (_placeSizeHeight - obj.GetHeight()) / 2
|
||||
);
|
||||
// прорисовка объекта
|
||||
obj.DrawTransport(g);
|
||||
if (obj != null) {
|
||||
obj.SetPosition(
|
||||
(placesRowCount - 1) * _placeSizeWidth - (i % placesColumnCount * _placeSizeWidth) + (_placeSizeWidth - obj.GetWidth()) / 2,
|
||||
i / placesColumnCount * _placeSizeHeight + (_placeSizeHeight - obj.GetHeight()) / 2
|
||||
);
|
||||
// прорисовка объекта
|
||||
obj.DrawTransport(g);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,4 +59,8 @@ public class SetGeneric<T extends DrawingPlane> {
|
||||
// Вставка в список по позиции
|
||||
_places.set(position, plane);
|
||||
}
|
||||
|
||||
public ArrayList<T> GetEnumerator() {
|
||||
return _places;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user